← Back to Menus & Validation
Question 471
Add Or Multiply Menu
Add Or Multiply Menu
Show the menu 1) Add, 2) Multiply, 3) Quit and read the choice with the prompt Choice: , stripped. Choices 1 and 2 each read two whole numbers with the prompts First: and Second: (converted with int(), read inside the branch so quitting never asks for numbers) and print Result: <n> with their sum or their product; choice 3 prints Goodbye! and leaves the loop; anything else prints Unknown choice - try again.. Input: one line per choice or number, ending with 3. Prompts are part of the output, so the two number prompts and the result share a line with Choice: .
Expected Output:
1) Add 2) Multiply 3) Quit Choice: First: Second: Result: 9 1) Add 2) Multiply 3) Quit Choice: First: Second: Result: 20 1) Add 2) Multiply 3) Quit Choice: Goodbye!
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Menus & Validation
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (pr, inp, def)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.