Reference no: EM132356731
#1 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
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 Analyze the following code. If you (hypothetically) check the condition count < 100 at the positions in the code designated as # Point A, # Point B, and # Point C, will the condition evaluate to always True, always False, or sometimes True and sometimes False? Give your answer for all the three positions
count = 0
while count < 100:
# Point A
print("Programming is fun!")
count += 1 #
Point B #
Point C
#3 How many times does the body of the while loop repeat? What is the output of each loop?
i = 1
while i< 10:
if i % 2 == 0:
print(i)
i += 1