Question: Part 1: Define a function named 'calc' that takes two numbers and an operator and returns the calculation result. The operator could be either '
Part 1: Define a function named 'calc' that takes two numbers and an operator and returns the calculation result. The operator could be either ' +1,1,1,1,1,11, or only. If the operator is "/", then divide the first number by the second. If the operator is 11, raise the first number to the second number' th power. menu = 11 Please choose one of the following operations to perform: 0. Nothing 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Exponentiation wiin print(menu) option = input( ('Type the operation number and press Enter: ') num1 = input ('Please enter the first number:' ') num 2 = input ('Please enter the second number:') Part 2: The above code will display a menu to the user prompting the user to choose a calculation to perform then two numbers. (You can comment them out by selecting the code and press CtrL+/ when you test the following code and don't want to run this part because it waits for you to type inputs.) After the user enters the two numbers, call 'calc' with the entered numbers and the corresponding operator. Display the calculation result. You need to map the option numbers to the corresponding operators required by the function 'calc
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
