Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

Python Program to Find Greatest of Two Numbers

Find Greatest of two Numbers​

In this Python program, we will find the greatest of two number. This program will ask the user to insert the two numbers as an input, first and second. With the use of If – Else statement, we will compare both the numbers. If first is greater than second, then it will print , ‘First is greater than second’, otherwise “It will print second is greater than first”.
For Example:
First: 56
Second: 89
Second is Greater than First
Python Program to Find Greatest of Two Numbers

Working:

Step 1: Start

Step 2: Enter two integers First and Second with the help of Input function and for converting user input() in int, we will use int() function as well.

Step 3: Check if the First is bigger in value than Second using if statement.

Step 4: If First is greater, then print, “First is Greater than Second” using the print function

Step 5: , If the condition is false then  print, “Second is Greater than First”

Step 6: Stop

Python Program:

first = int(input("Enter first number:"))
second = int(input("Enter second number:"))
if first > second:
    print("First is Greater than Second")
else:
    print("Second is Greater than First")

Output:

Enter first number:56
Enter second number:89
Second is Greater than First