Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

write a python program that prompts the user to enter three numbers and…

Question

write a python program that prompts the user to enter three numbers and checks which number is the smallest. print out an appropriate message depending on the input.

Explanation:

Step1: Get user input

num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))

Step2: Compare numbers and find smallest

smallest = num1
if num2 < smallest:
    smallest = num2
if num3 < smallest:
    smallest = num3

Step3: Print message

print(f"The smallest number is {smallest}")

Answer:

num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
num3 = float(input("Enter the third number: "))
smallest = num1
if num2 < smallest:
    smallest = num2
if num3 < smallest:
    smallest = num3
print(f"The smallest number is {smallest}")