subject

Step 1:Write code that calls a function named printMenu() The printMenu() function will:
print the menu below
ask the user to input a value between 1 an 12
return an integer value to your main program.
In the main part of your program print the value entered by the user. Use a print statement that is appropriate, not simply a print statement with the value.
Completed:
def myMenu(numArg):
print('\t1) - Category')
print('\t2) - Item')
print('\t3) - Serving Size')
print('\t4) - Calories')
print('\t5) - Calories from Fat')
print('\t6) - Total Fat')
print('\t7) - Cholestrol')
print('\t8) - Sodium')
print('\t9) - Carbs')
print('\t10) - Protein')
print('\t11) - Sugar')
print('\t12) - Done')
choice = int(input('Enter a number between 1 and 12:'))
return choice
# Main code
somenum = 10
myInput = myMenu(somenum)
print('The user entered: choice:', myInput)
Stage 2 (done)
Keep the following requirements from Stage #1
Write code that calls a function named printMenu()
The printMenu() function will:
print the menu below
ask the user to input a value between 1 an 12
return an integer value to your main program.
Within the printMenu() function:
I STRONGLY SUGGEST THAT YOU DO THESE ONE AT A TIME - get the loop working before you move to the next one - get the check working before you add the try/except
Add a loop to allow the user to continue to enter input until they enter a value between 1 and 12
Add code to catch input values less than 1 and greater than 12
Add a try/except block to catch a ValueError if the user inputs an alphabetic character/string
Create a function named processInput()
Pass a single argument to the function - this will be the value returned from the printMenu() function
The processInput() function will simply print the value of the argument passed in.
Use a different variable name in your main code and in your function

Completed:

def myMenu():
print('\t1) - Category')
print('\t2) - Item')
print('\t3) - Serving Size')
print('\t4) - Calories')
print('\t5) - Calories from Fat')
print('\t6) - Total Fat')
print('\t7) - Cholestrol')
print('\t8) - Sodium')
print('\t9) - Carbs')
print('\t10) - Protein')
print('\t11) - Sugar')
print('\t12) - Done')

def processInput(choice):
print('The user entered choice: ',choice)

def printMenu():
while True:
try:
myMenu()
choice = int(input('Enter a number between 1 and 12. '))
if choice > 12:
print('Enter a number between 1 and 12. ')
else:
return choice
except ValueError:
print('Invalid number enter.')

def main():
choice=printMenu()
processInput(choice)

main()

Stage 3 (help!)
Keep all of the requirements from Stage #2
Within the processInput() function:
Create a list named headings[]
the headings list should contain all the Headings from the menu except 'Quit'...so you have all 11 elements in the list from your menu.
Using the value that is passed into the processInput() function print not only the numerical value of that argument - but also print the proper item from the headings[] list.

At the TOP of you main code you need to place your code that read the file

The code to read and prepare this file is below

#Global variable
data = []

# Open the data file
infile = open("Mac_menu. csv", "r")

# Read the header line
line = infile. readline()

# Read each line of the file
for line in infile:

# strip the '\n' character
line = line. rstrip("\n")
# Split the line of input on the commas
# THEN create a tuple from those elements
result = tuple(line. split(","))
# Append the tuple onto the list named 'data'
data. append(result)

infile. close()

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:00
Are special characters that allow you to search for multiple words at the same time.
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. this can be done by normalizing to values between 0 and 1, or throwing away outliers. for this program, adjust the values by subtracting the smallest value from all the values. the input begins with an integer indicating the number of integers that follow. ex: if the input is 5 30 50 10 70 65, the output is: 20 40 0 60 55
Answers: 1
question
Computers and Technology, 24.06.2019 17:50
Which of the following best describe how the depth-limited search works. a normal depth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but the number of ply/depths is limited. a normal breadth-first search is performed but values above a specific value will be ignored. a normal depth-first search is performed but values above a specific value will be ignored.
Answers: 1
You know the right answer?
Step 1:Write code that calls a function named printMenu() The printMenu() function will:
pri...
Questions
question
Mathematics, 17.02.2020 19:49
question
Mathematics, 17.02.2020 19:49
question
English, 17.02.2020 19:49
question
English, 17.02.2020 19:50
Questions on the website: 13722365