Python Program to find largest of two numbers using function

In this program, You will learn how to find the largest of two numbers using function in Python.


def largest(x, y):
    if x > y:
        return True
    else:
        return False

Python Program to find largest of two numbers using function

Example: How to find largest of two numbers using function in Python.

def largest(x, y):
    if x > y:
        return x
    else:
        return y


x = int(input("Enter first number:"))
y = int(input("Enter second number:"))

result = largest(x, y)

print("Largest is:", result)

Output:

Enter first number:10
Enter second number:8
Largest is: 10