Take three numbers as arguments and returns the largest of them

Take three numbers as arguments and returns the largest of them.

A function max_of_three() that takes three numbers as arguments and returns the largest of them.

Users can enter any three numbers from the key-board and then we can find that among that three numbers which is the greatest number. If you want to find the least number then also you can find it.

Algorithm: To find the largest number with 3 numbers

  • Step1. start
  • Step2. define max function
  • Step3. In max function read a, b, c
  • Step4. check the condition a>b and a>c
  • Step5.If the condition is true return a
  • Step6. Otherwise check the condition b>c
  • Step7. If the condition is true return b Otherwise return c
  • Step8. declare the variables a,b,c, and read them.
  • Step9. Print the largest of three numbers.
  • Step10. End   Program:

 Source Code: Python Program to Find the Largest Among Three Numbers

def max(a,b,c):

if (a>b and a>c):

return a

elif(b>c):

return b

else:

return c

a=int(input('enter a:'))

b=int(input('enter b:'))

c=int(input('enter c:'))

ans=max(a,b,c)

print('largest of three numbers=', ans)

Output:

enter a:23
enter b:33
enter c:23
largest of three numbers= 33

find the largest number with 3 numbers

Recommended Posts:

Get Salesforce Answers

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



Leave a Comment