Question

can anyone show me how this code would look in python, I'm studying python while taking...

can anyone show me how this code would look in python, I'm studying python while taking some classes. I can't seem to understand what this is asking for.

• Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional coding will result in the loss of point.

• code will have the main function, including looping until the user enters input of 12

• code will call the printMenu() function

• The printMenu() function will have the capability to print the menu and receive input. AT THIS TIME do not worry about implementing the try/except code

• code will return the integer value (remember - the input() function returns a string) entered by the user to the main function.

• code will have a simple print statement outputting the statement "The user input the value ??" - where the ?? will be replaced by the value the user entered.

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

def printMenu():
   print('Select from the following options:')
   print('\t 1) Category')
   print('\t 2) Item')
   print('\t 3) Serving Size')
   print('\t 4) Calories')
   print('\t 5) Calories from Fat')
   print('\t 6) Total Fat')
   print('\t 7) Cholestrol')
   print('\t 8) Sodium')
   print('\t 9) Carbohydrates')
   print('\t 10) Protein')
   print('\t 11) Sugars')
   print('\t 12) Quit')
   cmd = int(input('Enter Number Command: '))
   return cmd

def main():
   choice = None
   while choice != 12:
       choice = printMenu()
       print('The user input the value', choice)
       print()

main()

1 2 3 5 6 7 8 def printMenu(): print(Select from the following options:) print(\t.1). Category) print(\t.2). Item) prin

Add a comment
Know the answer?
Add Answer to:
can anyone show me how this code would look in python, I'm studying python while taking...
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
  • Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional...

    Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional coding will result in the loss of point. code will have the main function, including looping until the user enters input of 12 code will call the printMenu() function theprintMenu() function will have the capability to print the menu and receive input. AT THIS TIME do not worry about implementing the try/except code code will return the integer value (remember - the input() function...

  • STAGE 1 In Stage #2 here are the requirements: • Keep the following requirements from Stage...

    STAGE 1 In Stage #2 here are the requirements: • Keep the following requirements from Stage #1 o 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: o I STRONGLY SUGGEST THAT YOU DO THESE ONE AT A TIME - get the loop working before...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • Use python to code! Q1 - You need to keep track of book titles. Write code...

    Use python to code! Q1 - You need to keep track of book titles. Write code using function(s) that will allow the user to do the following. 1. Add book titles to the list. 2. Delete book titles anywhere in the list by value. 3. Delete a book by position. Note: if you wish to display the booklist as a vertical number booklist , that is ok (that is also a hint) 4. Insert book titles anywhere in the list....

  • using this code to complete. it python 3.#Display Program Purpose print("The program will show how much...

    using this code to complete. it python 3.#Display Program Purpose print("The program will show how much money you will make working a job that gives a inputted percentage increase each year") #Declaration and Initialization of Variables userName = "" #Variable to hold user's name currentYear = 0 #Variable to hold current year input birthYear = 0 #Variable to hold birth year input startingSalary = 0 #Variable to hold starting salary input retirementAge = 0 #Variable to hold retirement age input...

  • Hi. Please help me solve this in python using only while loops, if statements. Can't use...

    Hi. Please help me solve this in python using only while loops, if statements. Can't use for loops and lists. In this programming assignment, you will be writing a program that prints out several shapes via text. In this PA, you will be required to use functions and parameters. This is both to reduce redundancy and to make your code clean and well-structured. Name your program shaper.py Your program should have the capability to print out three different shapes: An...

  • Can you help me rearrange my code by incorporating switch I'm not really sure how to...

    Can you help me rearrange my code by incorporating switch I'm not really sure how to do it and it makes the code look cleaner. Can you help me do it but still give the same output? Also kindly add an in-line comment on what changes and rearrangement you've done so I can understand what's going on. import java.util.ArrayList; import java.util.Scanner; public class Bank { /** * Add and read bank information to the user. * @param arg A string,...

  • Can you add code comments where required throughout this Python Program, Guess My Number Program, and...

    Can you add code comments where required throughout this Python Program, Guess My Number Program, and describe this program as if you were presenting it to the class. What it does and everything step by step. import random def menu(): #function for getting the user input on what he wants to do print("\n\n1. You guess the number\n2. You type a number and see if the computer can guess it\n3. Exit") while True: #using try-except for the choice will handle the...

  • 1) Translate the following equation into a Python assignment statement 2) Write Python code that prints...

    1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...

  • In this lab you will code a simple calculator. It need not be anything overly fancy,...

    In this lab you will code a simple calculator. It need not be anything overly fancy, but it is up to you to take it as far as you want. You will be creating this program in three small sections. You have the menu, the performance of the basic arithmetic operations (Addition, Subtraction Multiplication, and Division), and the looping. You may want to get the switch menu working first, and then fill in the code for these four arithmetic operations...

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
ADVERTISEMENT