52 Program for function to add 2 numbers in Python

Program 1:

# function to add 2 nos

x=int(input("enter value of x: "))    #global variable

y=int(input("enter value of y: "))

def add():

    z=x+y                             #local variable

    print("sum of",x,"and",y,"is",z)

add()#function call


Output:

Program for function to add 2 numbers in Python

Previous
Next Post »