Answered step by step
Verified Expert Solution
Question
1 Approved Answer
pls help me with my homework tq Activity #1 Write a Python program that asks the user to enter two numbers and a letter to
pls help me with my homework tq
Activity #1 Write a Python program that asks the user to enter two numbers and a letter to represent each operation (+,-*,7). Then, the program should perform the selected calculation and display its result accordingly. Sample of output is shown below: Enter 2 numbers and perform calculation Enter first number: 50 Enter second number: 90 ----Select operation. [A]dd [S]ubtract [M]ultiply [D]ivide Enter choice (A/ S/M/D):m -----Calculating------ 50 * 90 = 4500 NOTE: Search the Net and check on the use of upper built in function. Activity #2 Rewrite the program in activity #1 by adding suitable loop structure that will allow user to key-in the numbers and select its operation repetitively until user press letter Q to end the program. In performing division operation, the program should avoid the division by zero logic error (when user key in letter D and the denominator is 0). It should request the user to re-enter the denominator and it must not be 0. The program will also check for an invalid letter entered by user. If user key-in letter other than the listed option, an invalid input message will be displayed, and they may enter a new letter. Then only, the user may proceed with the calculation. Sample of outputs are shown below: Enter 2 numbers and perform calculation Enter first number: 789 Enter second number: 0 ----Select operation.--- [A] dd [S]ubtract [M] ultiply [D]ivide [Q]uit Enter choice (A/S/M/D/Q) :D ---Calculating---- Denominator cannot be 0. Enter another number: 0 Denominator cannot be 0. Enter another number: 5 789 / 5 = 157.8 Enter 2 numbers and perform calculation Enter first number: 345 Enter second number: 543 ----Select operation.- [A] dd [S]ubtract [M] ultiply [D] ivide [Q]uit Enter choice (A/S/M/D/Q) :add You have entered invalid input.Enter a valid input Enter choice (A/ S/M/D/0) :ADD You have entered invalid input.Enter a valid input Enter choice (A/ S/M/D/Q) :IStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started