Python Program to subtract two numbers using the function


In this program, you will learn how to subtract two numbers using the function in Python.


20 = 30 - 10

10 = 20 - 10

Example: How to subtract two numbers using the function in Python.

def subtraction(p, q):
    z = p - q
    return z


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

result = subtraction(x, y)
print("Subtraction of two numbers:", result)

Output:

Enter first number:10
Enter second number:5
Subtraction of two numbers: 5