codescracker


python

Python Program to Find Largest of Three Numbers



« Previous Program Next Program »


Find Largest of Three Numbers in Python

To find largest or greatest of three numbers in python, you have to ask from user to enter three numbers to find and print the largest one among these three numbers as shown in the program given here.

Python Programming Code to Find Largest of Three Numbers

Following python program ask from user to enter any three numbers and then find the largest one:

# Python Program - Find Largest of Three Numbers
		
while True:
	print("Enter 'x' for exit.")
	print("Enter any three numbers: ")
	num1 = input()
	num2 = input()
	num3 = input()
	if num1 == 'x':
		break
	else:
		number1 = int(num1)
		number2 = int(num2)
		number3 = int(num3)
		largest = number1
		if largest < number2:
			if number2 > number3:
				largest = number2
			else:
				largest = number3
		elif largest < number3:
			if number3 > number2:
				largest = number3
			else:
				largest = number2
		else:
			largest = number1
		print("Largest of given three numbers is",largest,"\n")

Here are some sample runs of the above python program illustrating how to find largest of three numbers. This is first snapshot:

python find largest of three numbers

This is second snapshot:

find largest among three numbers in python

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 »




Tools
Calculator

Quick Links
Signup - Login - Give Online Test