Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using python Problem 3 (10 points). Write a program which gives the option betwe

ID: 3857082 • Letter: U

Question

Using python Problem 3 (10 points). Write a program which gives the option between doing 3 things: 1) Add two numbers 2) Multiply three numbers 3) Multiply a number and a string Ask the user to choose an option. Output “Invalid option” if the user enters something apart from 1, 2 or 3. Otherwise depending on what the user enters ask the user again for inputs to perform the required choice and output the answer.
Sample program output 1: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 2 Please enter number 1: 2 Please enter number 2: 3 Please enter number 3: 5 The answer is 30
Sample program output 2: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 3 Please enter a string: hello Please enter a number: 3 The answer is hellohellohello Instructor: Ishan Behoora Spring 2017 Using python Problem 3 (10 points). Write a program which gives the option between doing 3 things: 1) Add two numbers 2) Multiply three numbers 3) Multiply a number and a string Ask the user to choose an option. Output “Invalid option” if the user enters something apart from 1, 2 or 3. Otherwise depending on what the user enters ask the user again for inputs to perform the required choice and output the answer.
Sample program output 1: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 2 Please enter number 1: 2 Please enter number 2: 3 Please enter number 3: 5 The answer is 30
Sample program output 2: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 3 Please enter a string: hello Please enter a number: 3 The answer is hellohellohello Instructor: Ishan Behoora Spring 2017 Problem 3 (10 points). Write a program which gives the option between doing 3 things: 1) Add two numbers 2) Multiply three numbers 3) Multiply a number and a string Ask the user to choose an option. Output “Invalid option” if the user enters something apart from 1, 2 or 3. Otherwise depending on what the user enters ask the user again for inputs to perform the required choice and output the answer.
Sample program output 1: You can choose between: 1) Adding two numbers Problem 3 (10 points). Write a program which gives the option between doing 3 things: 1) Add two numbers 2) Multiply three numbers 3) Multiply a number and a string Ask the user to choose an option. Output “Invalid option” if the user enters something apart from 1, 2 or 3. Otherwise depending on what the user enters ask the user again for inputs to perform the required choice and output the answer.
Sample program output 1: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 2 Please enter number 1: 2 Please enter number 2: 3 Please enter number 3: 5 The answer is 30 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 2 Please enter number 1: 2 Please enter number 2: 3 Please enter number 3: 5 The answer is 30
Sample program output 2: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 3 Please enter a string: hello Please enter a number: 3 The answer is hellohellohello Instructor: Ishan Behoora Spring 2017 Sample program output 2: You can choose between: 1) Adding two numbers 2) Multiplying three numbers 3) Multiplying a number and a string Please choose an option: 3 Please enter a string: hello Please enter a number: 3 The answer is hellohellohello Instructor: Ishan Behoora Spring 2017

Explanation / Answer

print "You can choose between:
1) Adding two numbers
2) Multiplying three numbers
3) Multiplying a number and a string"
try:
mode=int(raw_input('Please choose an option: '))
if mode == 1 :
num1=int(raw_input('Please enter number 1: '))
num2=int(raw_input('Please enter number 2: '))
ans = num1 + num2
print 'The answer is: '+str(ans)
elif mode == 2 :
num1=int(raw_input('Please enter number 1: '))
num2=int(raw_input('Please enter number 2: '))
num3=int(raw_input('Please enter number 3: '))
ans = num1*num2*num3
print 'The answer is: '+str(ans)
elif mode == 3 :
string=str(raw_input('Please enter a string: '))
num=int(raw_input('Please enter a number: '))
ans =string*num
print 'The answer is: '+str(ans)
else:
print("Invalid option")
except ValueError:
print "Invalid option"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote