Python Program to Find the Greatest of the Three                                                        Numbers

Find the Greatest of Three Numbers in Python

Given three integers num1, num2, and num3 as inputs.

The objective is to write a code to Find the Greatest of the Three Numbers in Python Language. To do so we’ll check the numbers with each other and print the largest of them all.

Example

Input : num1 = 2 num2 = 9 num3 = 4

Output : 9

Flow Diagram:-

Greatest of the Three numbers.jpg

Code:-

  • Declare a variable a, b, c and largest as integer;

  • Read the number a, b and c;

  • max = a > b ? (a > c ? a : c) : (b > c ? b : c);

  • print max;

Algorithm:-

Code:-

num1, num2, num3 = 10 , 15 , 20
max = 0
if num1 >= num2 and num1 >= num3:
  print(num1)
elif num2 >= num1 and num2 >= num3:
  print(num2)
else:
  print(num3)

Output:-

Enter a number: 10 15 20

20 is the greatest