Program to find the maximum of three numbers.

In this python function program, we will find the maximum of three numbers.

What is Function?
It is a block of code that executes when it is called.
To create a function use def keyword.

Steps to solve the program
  1. Create a function largest
  2. Use the def keyword to define the function.
  3. Pass three parameters i.e. numbers to the function.
  4. Take 3 numbers as input through the user and pass them to the function while calling the function.
  5. Find the largest number among three numbers using logic and if-else statements.
				
					def largest(a,b,c):
    if a>b:
        if a>c:
            print(f"{a} is the greatest number")
    elif b>a:
        if b>c:
            print(f"{b} is the greatest number")
    else:
        print(f"{c} is the greatest number")
        
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
num3 = int(input("Enter number 3: "))

largest(num1,num2,num3)
				
			

Output :

				
					Enter number 1: 50
Enter number 2: 60
Enter number 3: 44
60 is the greatest number
				
			

Related Articles

print a table of a given number.

find the sum of all the numbers in a list.

Leave a Comment