Python program to find the greatest of the three numbers

  • This python example will check the greatest of given numbers
  • Ask user to enter 3 numbers
  • Assign user enter 3 numbers to variables x,y,z by converting them to integers
  • Now check the variable x, by writing if condition to check the var y is lessthan x and x is greater than z then will print x is greatest from given numbers
  • Now check the variable y, by writing if condition to check the var x is lessthan y and y is greater than z then will print y is greatest from given numbers
  • Now check the variable z, by writing if condition to check the var z is lessthan y and z is greater than y then will print z is greatest from given numbers
x = int(input("Insert first number: "))
y = int(input("Insert second number: "))
z = int(input("Insert third number: "))

print("The maximum number is : ", end="")
if y <= x >= z:
    print(x)
elif x <= y >= z:
    print(y)
elif x <= z >= y:
    print(z)

 

Output:

Insert first number: 12
Insert second number: 2
Insert third number: 25
The maximum number is : 25

 

Subscribe For Daily Updates

100+ Python Pattern Examplespython pattern examples - star patterns, number patterns