Question

2- Create Python file to allow the Digital Library Website projects to select one of the web pages in the website (A: Books

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python Code for the above problem:

import sys #Importing sys module for terminating the execution

def function(choice):
if choice == "a" or choice == "A": #If the user enters "a" or "A"
return "\t\t\t Welcome to Books Online \n" #Return the string "Welcome to Books Online"
  
  
elif choice == "b" or choice == "B": #If the user enters "b" or "B"
return "\t\t\t Welcome to Collections \n" #Return the string "Welcome to Collections"
  
elif choice == "c" or choice == "C": #If the user enters "c" or "C"
return "\t\t\t Welocme to Research \n" #Return the string "Welcome to Research"
  
  
elif choice == "q" or choice == "Q": #If the user enters "q" or "Q"
sys.exit() #Terminating the execution using "sys" module
  

def main():
while True: #This is an infinite loop
print("\t************ Welcome to Digital Library Web Site ************ \n")
print("\t\t\t\t A: Books Online \n") #Printing the options for the user
print("\t\t\t\t B: Collections \n")
print("\t\t\t\t C: Research \n")
print("\t\t\t\t Q: Log Out or Quit\n")
choice = input("\t\t\tPlease enter your choice: ") #Prompting the user to enter his/her choice
print()
print(function(choice)) #Calling the function to process the request
  
  
main() #Calling out main function


CODE IMPLEMENTATION:

File Edit Format Run Options Window Help import sys #Importing sys module for terminating the execution def function (choice)CODE IMPLEMENTATION OUTPUT (1):

*** Welcome to Digital Library Web Site A: Books Online B: Collections C: Research Q: Log Out or Quit Please enter your choicCODE IMPLEMENTATION OUTPUT (2):

What if the user enters the option "Q":

*** Welcome to Digital Library Web Site ** A: Books Online B: Collections C: Research Q: Log Out or Quit Please enter your chi.e., When the user enters "Q" The program execution will terminate..Oterwise the program goes on prompting the user to enter his/her choice...

NOTE:

# Be aware of the indentation by observing the above uploaded CODE pictures.

# I have used sys.exit() statement to stop the execution when the user enters the input as "Q"

# Or else we can just put a break statement in the while loop to stop execution.


Add a comment
Know the answer?
Add Answer to:
2- Create Python file to allow the "Digital Library Website" projects to select one of the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this project, you will construct an Object-Oriented framework for a library system. The library must...

    In this project, you will construct an Object-Oriented framework for a library system. The library must have books, and it must have patrons. The patrons can check books out and check them back in. Patrons can have at most 3 books checked out at any given time, and can only check out at most one copy of a given book. Books are due to be checked back in by the fourth day after checking them out. For every 5 days...

  • 3. Consider the steps you take when shopping online on Amazon or any other website of...

    3. Consider the steps you take when shopping online on Amazon or any other website of your choice. Assume that the starting point is when you have found the desired product (Meaning that the research for selecting a product among various vendors is out of this process boundary). The product is available in different colors and sizes. The end point of this process is when you receive the “confirmation of order” message on the web page. 3-1. Create a process...

  • Objectives This is one of three major programming projects this semester. You should NOT collaborate on...

    Objectives This is one of three major programming projects this semester. You should NOT collaborate on this project. While you may ask for assistance in debugging, this project should be ENTIRELY your own work. Objectives include: . Use local variables. • Use arithmetic expressions. • Use Scanner to input values. • Use a class constant. • Use of nested branches. • Use for loxops. • Use of methods. • Use of arrays. Hand-in Requirements All projects and laboratories will be...

  • Create one program using these three programs: 1. Payroll Calculator Need to include state tax amount...

    Create one program using these three programs: 1. Payroll Calculator Need to include state tax amount and SS amount Net pay need to reflect those amount Need to make all the amounts with 2 decimal points. Hint See line #31 - Use the programming outline/format discussed in the lecture, with proper documentation, data declaration, etc. - When asking a user for data, provide user-friendly and clear direction - Same thing for the output. - Include code and screenshot of the...

  • C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use...

    C++ Fraction calculator Need help with code, cant use "using namespace std" Objectives Create and use functions. Use a custom library and namespace. Use reference variables as parameters to return values from functions. Create a robust user interface with input error checking. Use exceptions to indicate errors. Resources kishio.h kishio.cpp Assignment requirements You will need eight methods (including main). One is given to you. Their requirements are specified below: menu: The menu function takes no arguments, but returns a char...

  • First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below...

    First, read the article on "The Delphi Method for Graduate Research." ------ Article is posted below Include each of the following in your answer (if applicable – explain in a paragraph) Research problem: what do you want to solve using Delphi? Sample: who will participate and why? (answer in 5 -10 sentences) Round one questionnaire: include 5 hypothetical questions you would like to ask Discuss: what are possible outcomes of the findings from your study? Hint: this is the conclusion....

  • CASE 8 Unlocking the Secrets of the Apple iPhone in the Name of access the male...

    CASE 8 Unlocking the Secrets of the Apple iPhone in the Name of access the male San Bernardino suspect's iPhone 5c. Cook stated: Antiterrorism We are challenging the FBI's demands with the deepes respect for American democracy and a love of our country. We believe it would be in the best interest of everyone to step back and consider the implications While we believe the FBI's intentions are good, if would be wrong for the w e nt to force...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT