Question

In: Computer Science

Menu Writing - Python - Please include #Comments in each line for explanation (a) A common...

Menu Writing - Python - Please include #Comments in each line for explanation

(a) A common task while writing any software is to display a menu and ask the user for a choice. One such example is the menu on your cellphone. It has messaging, contacts, games, settings, media, and web (and possibly others) as options. Write a function called display menu that displays the menu to the user and allows the user to make a choice (using input).

(b) Write a function that takes the choice of the user and makes calls to the other functions that correspond to the operation to be performed. (Give meaningful

names to the functions. You don’t have to write the other function definitions.)

Solutions

Expert Solution

def display_menu():
   print "Choose one of the following:"
   print "1. messaging"
   print "2. contacts"
   print "3. games"
   print "4. settings"
   print "5. media"
   print "6. web"
   print "0. exit"

   print "input any of number from 1 to 6"
  

def choose(choice):
   if choice == 1:
       messaging()

   elif choice == 2:
       contacts()

   elif choice == 3:
       games()

   elif choice == 4:
       settings()

   elif choice == 5:
       media()

   elif choice == 6:
       web()

def main():

   while True:
       display_menu()
       choice = int(raw_input())
       while choice < 0 or choice > 6:
           print "invalid input, try again"
           choice = int(raw_input())
       if choice == 0:
           return

       choice(choice)

if __name__ == "__main__":
   main()


Related Solutions

PLEASE INCLUDE #FOR EACH LINE EXPLANATION Write a PYTHON PROGRAM that prompts for an integer and...
PLEASE INCLUDE #FOR EACH LINE EXPLANATION Write a PYTHON PROGRAM that prompts for an integer and prints the integer, but if something other than an integer is input, the program keeps asking for an integer. Here is a sample session: Input an integer: abc Error: try again. Input an integer: 4a Error: try again. Input an integer: 2.5 Error: try again. Input an integer: 123 The integer is: 123 Hint: the string isdigit method will be useful to solve this...
Assembly language: please comment on every line of code explaining each part. include head comments describing...
Assembly language: please comment on every line of code explaining each part. include head comments describing what your program does. Assignment 3A - A program that adds and subtracts 32-bit numbers After installing the assembler on the computer, enter the following program, save it, assemble it and run it. Do not forget to add a comment with your name in it. You will hand in a listing (e.g., addsum.asm) that should include your name ________________________________________ TITLE Add and Subtract (AddSum.asm)...
Please include comments on what you are doing.   Using linked lists, write a Python program that...
Please include comments on what you are doing.   Using linked lists, write a Python program that performs the following tasks: store the records for each college found in the input file - colleges.csv - into a linked list. (File includes name and state data fields) allow the user to search the linked list for a college’s name; display a message indicating whether or not the college’s name was in the database allow the user to enter a state's name and...
simple python program : include comments please Let's continue to practice an example using the PriorityQueue...
simple python program : include comments please Let's continue to practice an example using the PriorityQueue from the queue module in Python: Suppose you have been tasked with writing a program that will track the registration waiting list for CCIS 100. Priority is given to seniors, then juniors, etc... Generate a text file (named waitlist.txt) containing the number of credit hours earned, ID number, and email of students who request to be added to the waitlist (1 piece of data...
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would...
PYTHON PLEASE!! ALSO: if you can include an explanation of what the code means that would be appreciated 8.19 LAB*: Program: Soccer team roster (Dictionaries) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers and the ratings in a...
Please write python code for the following. Implement the functions defined below. Include a triple-quoted comments...
Please write python code for the following. Implement the functions defined below. Include a triple-quoted comments string at the bottom displaying your output. Using sets (described in Deitel chapter 6) will simplify your work. Below is the starter template for the code: def overlap(user1, user2, interests): """ Return the number of interests that user1 and user2 have in common """ return 0    def most_similar(user, interests): """ Determine the name of user who is most similar to the input user...
Please Complete this C Code using the gcc compiler. Please include comments to explain each added...
Please Complete this C Code using the gcc compiler. Please include comments to explain each added line. /*This program computes the Intersection over Union of two rectangles as a percent: IoU = [Area(Intersection of R1 and R2) * 100 ] / [Area(R1) + Area(R2) - Area(Intersection of R1 and R2)] The answer will be specified as a percent: a number between 0 and 100. For example, if the rectangles do not overlap, IoU = 0%. If they are at the...
In java, (include javadoc comments for each method, please use ArrayList, not Array, and ensure that...
In java, (include javadoc comments for each method, please use ArrayList, not Array, and ensure that the program compiles). design a class named Contact that has fields for a person’s name, phone number and email address. The class should have a no-arg constructor and a constructor that takes in all fields, appropriate setter and getter methods. Then, write a program that creates at least five Contact objects and stores them in an ArrayList. In the program create a method, that...
Include an explanation with each entry.
Question Recording transactions from a bank reconciliation Review your results from preparing Guard Dog Security Systems’s bank reconciliation in Short Exercise S7-9. Journalize the company’s transactions that arise from the bank reconciliation. Include an explanation with each entry.
C++ program, include comments stating what each part of code does please. I want to be...
C++ program, include comments stating what each part of code does please. I want to be able to understand it so I'll be more knowledgeable in the future. The program is multiple files(fibonacci.h file, fibonacci.cpp file, main.cpp file and loops_simple_data_test.cpp). After the directions I also included any starter code or comments left by my professor within the files to aide us. Directions: In folder 04_loops_simple_data write prototype and definition for string value - return function get_fibonacci with an int parameter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT