Write a Program to input three numbers and print their sum if first number greater than 10 otherwise calculate their product
Answers
Answered by
4
Program
x = int(input("Enter the first number:\n"))
y = int(input("Enter the second number:\n"))
z = int(input("Enter the third number:\n"))
sum = x + y + z
product = x*y*z
if(x>10):
print("Good numbers.Well,their sum is", str(sum)+".")
else:
print("The numbers you entered when multiplied give", str(product)+".")
Explanation:
- I have used conditional expressions since a condition is given.
- The conditions on if statement is that x (first number) should be greater than 10. If the input satisfies this criteria, then only sum will be executed.
- If the first condition fails, else statement will be executed and we will get the products of the numbers we will enter.
Attachments:
Similar questions