Python Program to Find Largest of Two Numbers

This python program finds largest of two numbers given by user.

First, two numbers are read from user and stored in variable first and second. After that decision of largest in the program is made using python's if else statement.

Python Source Code: Largest of Two Numbers


# Finding largest of two numbers

# Reading numbers
first = float(input('Enter first number: '))
second = float(input('Enter second number: '))

# Making decision and displaying
if first > second:
    large = first
else:
    large = second

print('Largest = %d' %(large))

Python Largest of Two Numbers Output

Run 1:
------------------
Enter first number: 33
Enter second number: 23
Largest = 33

Run 2:
------------------
Enter first number: -45
Enter second number: 0
Largest = 0