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.
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': break else: number1 = int(num1) number2 = int(num2) if number1 > number2: largest = number1 else: largest = number2 print("Largest of entered two numbers is", largest,"\n")
Here is the sample run of the above Python program:
You may also like to learn or practice the same program in other popular programming languages: