Computer Science, asked by souravsinghstar14, 3 months ago

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

Answers

Answered by pragatibhatt2922
0

Answer:

Explanation:

Approach :

Read 3 input numbers using input() or raw_input() .

Use two functions largest() and smallest() with 3 parameters as 3 numbers.

largest(num1, num2, num3)

check if num1 is larger than num1 and num2, if true num1 is largest, else.

check if num2 is larger than num1 and num3, if true num2 is largest,

f both the above fails, num3 is largest

Print the largest number

smallest(num1, num2, num3)

check if num1 is smaller than num1 and num2, if true num1 is smallest, else

check if num2 is smaller than num1 and num3, if true num2 is smallest,

if both the above fails, num3 is smaller

Print the smallest number

Answered by harshvirsing55
0

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