Python Program to Find Largest of Two Numbers

« Previous Program Next Program »

Find Largest of Two Numbers in Python

To find largest or greatest of two numbers in python, you have to ask from user to enter the two numbers and then compare both the numbers with each other to find which one is largest and then display the largest number on the output screen as shown in the program given below.

Python Programming Code to Find Largest of Two Numbers

Following python program ask from user to enter two numbers to find and print the largest one:

# Python Program - Find Largest of Two Numbers
while True:
	print("Enter 'x' for exit.")
	print("Enter two numbers: ")
	num1 = input()
	num2 = input()
	if num1 == 'x':
		number1 = int(num1)
		number2 = int(num2)
		if number1 > number2:
			largest = number1
			largest = number2
		print("Largest of entered two numbers is", largest,"\n")

Here is the sample run of the above Python program:

python find largest of two numbers

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:

« Previous Program Next Program »


Quick Links
Signup - Login - Give Online Test