In this program, You will learn how to find largest of two numbers using function in Python.
10 20 => 20
15 11 => 15
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