Write a Python Program that displays repeatedly a menu as shown
in the sample run below. The user will enter 1, 2, 3, 4 or 5 for
choosing addition, substation, multiplication, division or exit
respectively. Then the user will be asked to enter the two numbers
and the result for the operation selected will be displayed. After
an operation is finished and output is displayed the menu is
redisplayed, you may choose another operation or enter 5 to exit
the program. All the Tasks has to be defined within functions and
named properly for example: addition(number1,number2) for the
function that calculates the addition of number 1 and number 2.
Define the menu within a function and define also a function that
takes as parameters the operation and the two numbers then return
the operation result by calling the appropriate defined function or
invalid operation otherwise. Make sure to comment your program
throughout the code. Requirements: • Appropriate variable and
function names • Appropriate Data types and conversions • Correct
mathematical calculations • Appropriate functions definitions and
calls • Fully commented program. • Correct loop structure •
Accurate output display
Sample Run:
Main Menu 1: Addition
2: Subtraction
3: Multiplication
4: Division
5: Exit
Enter a Choice: 1
Enter number 1: 5
Enter number 2: 4
The Answer is: 9
Main Menu
1: Addition
2: Subtraction
3: Multiplication
4: Division
5: Exit
Enter a Choice: 4
Enter number 1: 8
Enter number 2: 2
The Answer is: 4
Main Menu
1: Addition
2: Subtraction
3: Multiplication
4: Division
5: Exit
Enter a Choice: 5
Exiting… Thank you for using the Python Calculator!
#python code
def menu():
print("Main Menu\n\
1: Addition\n\
2: Subtraction\n\
3: Multiplication\n\
4: Division\n\
5: Exit")
def addition(num1, num2):
return (num1+num2)
def subtraction(num1, num2):
return (num1- num2)
def multiplication(num1, num2):
return num1*num2
def division(num1, num2):
if num2 == 0:
print("Can not divide by zero..")
else:
return num1/num2
if __name__ == "__main__":
while True:
menu()
choice = int(input("Enter a choice: "))
if choice == 1:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
print("The answer is: "+str(addition(num1, num2)))
elif choice == 2:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
print("The answer is: "+str(subtraction(num1, num2)))
elif choice == 3:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
print("The answer is: "+str(multiplication(num1, num2)))
elif choice == 4:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
print("The answer is: "+str(division(num1, num2)))
elif choice == 5:
print("Thanks for using this calc App...")
break
else:
print("Wrong choice... please try again..")
#screenshot for indentation help


#output

//If you need any help regarding this solution......... please leave a comment...... Thanks
Write a Python Program that displays repeatedly a menu as shown in the sample run below....
IN JAVA: Write a program that displays a menu as shown in the sample run. You can enter 1, 2, 3, or 4 for choosing an addition, subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter 5 to exit the system. Each test generates two random single-digit numbers to form a question for addition, subtraction, multiplication, or division. For a subtraction such as number1 – number2, number1 is...
Read description carefully. Needs to catch exceptions and still be
able to keep the program going on past the error. Program should
allow user to keep going until he or she quits
Math tutor) Write a program that displays a menu as shown in the sample run. You can enter 1, 2. 3, or 4 for choosing an addition. subtraction, multiplication, or division test. After a test is finished, the menu is redisplayed. You may choose another test or enter...
(For Python program) Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...
A Simple Calculator Summary: Write a console program (character based) to do simple calculations (addition, subtraction, multiplication and division) of two numbers, using your understanding of Java. Description: You need to write a program that will display a menu when it is run. The menu gives five choices of operation: addition, subtraction, multiplication, division, and a last choice to exit the program. It then prompts the user to make a choice of the calculation they want to do. Once the...
in python and use while loop
Exercise: Complete the program that performs basic arithmetic operations of two input numbers. The program displays a menu for user to select a desired operation. ===== MAIN MENU ===== 1. Addition 2. Subtraction 3. Exit Select an operation (1-3): 1 Enter two numbers: 12 20 12 + 20 - 32 - MAIN MENU 1. Addition 2. Subtraction 3. Exit Select an operation (1-3): 2 Enter two numbers: 12 20 12 - 10 = 2...
Question 20: Write a python program that will perform the operations of simple calculator. The operations are : Addition, subtraction, Multiplication and division. Sample output : Select operation. 1.Add 2.Subtract 3.Multiply 4.Divide Enter choice(1/2/3/4): 3 Enter first number: 15 Enter second number: 14 15 * 14 = 210
PLease IN C not in C++ or JAVA, Lab3. Write a computer program in C which will simulate a calculator. Your calculator needs to support the five basic operations (addition, subtraction, multiplication, division and modulus) plus primality testing (natural number is prime if it has no non-trivial divisors). : Rewrite your lab 3 calculator program using functions. Each mathematical operation in the menu should be represented by a separate function. In addition to all operations your calculator had to support...
Design a calculator program that will add, subtract, multiply, or divide two numbers input by a user.Your program should contain the following:-The main menu of your program is to continue to prompt the user for an arithmetic choice until the user enters a sentinel value to quit the calculatorprogram.-When the user chooses an arithmetic operation (i.e. addition) the operation is to continue to be performed (i.e. prompting the user for each number, displayingthe result, prompting the user to add two...
C Programming Homework Question 1. The task is to demonstrate the knowledge of using conditional statements and loops. The following incomplete command line-based program was written to mimic a simple calculator. At the current state, the program reads the first number (operand-1) digit by digit and allows the user to select the type of operation. #include <stdio.h> int main() { int count1=0, value=0, number1=0, operation=0; printf("Enter the first operand, one digit at a time ... or enter -1 to stop...
Write a C++ Program that simulates a basic calculator using functions which performs the operations of Addition, Subtraction, multiplication, and Division. ( make sure you cover the case to avoid division by a zero) Display a menu for list of operations that can be calculated and get the input from user about his choice of calculation. Based on user choice of operation, take the input of number/numbers from user. Assume all input values are of type double. Calculations must be...