Q.3 WAP to Input three numbers and display the largest / smallest number.

Solution  :- 

num1 = float(input("Enter the first number: ")) num2 = float(input("Enter the second number: ")) num3 = float(input("Enter the third number: ")) if num1 >= num2 and num1 >= num3: largest = num1 elif num2 >= num1 and num2 >= num3: largest = num2 else: largest = num3 if num1 <= num2 and num1 <= num3: smallest = num1 elif num2 <= num1 and num2 <= num3: smallest = num2 else: smallest = num3 print(f"Largest number: {largest}") print(f"Smallest number: {smallest}")

Output :- 

Leave a Reply

Your email address will not be published. Required fields are marked *

sign up!

We’ll send you the hottest deals straight to your inbox so you’re always in on the best-kept software secrets.