Computer Science, asked by souravsinghstar14, 4 months ago

WAP in python to find the largest and smallest number in three numbers entered by user​

Answers

Answered by pragatibhatt2922
0

Answer:

Explanation:

Source Code:

# Python program to find the largest number among the three input numbers

# take three numbers from user

num1 = float(input("Enter first number: "))

num2 = float(input("Enter second number: "))

num3 = float(input("Enter third number: "))

 

if (num1 > num2) and (num1 > num3):

  largest = num1

elif (num2 > num1) and (num2 > num3):

  largest = num2

else:

  largest = num3

 

print("The largest number is",largest)

Output 1:

Enter first number: 10

Enter second number: 12

Enter third number: 14

The largest number is 14.0

Output 2:

Enter first number: -1

Enter second number: 0

Enter third number: -3

The largest number is 0.0

Explanation

In this program, we ask the user to input three numbers. We use the if…elif…else ladder to find the largest among the three and display it.

Answered by harshvirsing55
4

Answer:

a=int(input('Enter your 1st no. ='))

b=int(input('Enter your 2nd no. ='))

c=int(input('Enter your 3rd no. ='))

#for largest no.

if (a > b) and (a > c):

  max = a

elif (b > a) and (b > c):

  max = b

else:

  max = c

   

#For smallest no.

if (a < b) and (a < c):

       min = a

elif (b < a) and (b < c):

   min = b

else:

   min = c  

print("Largest no. is",max,"\nsmallest no. is" ,min)

Thankyou : )

Similar questions