Python Program to add two numbers using the function


In this program, You will learn how to add two numbers using a function in Python.


20 = 10 + 10

30 = 20 + 10

Example: How to add two numbers using a function in Python.

def add(a, b):
    s = a + b
    return s


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

result = add(x, y)

print("Sum is:", result)

Output:

Enter first number:10
Enter second number:20
Sum is: 30