Function in Python

 #function

def priya():

    print("hello i am function")

    a=int(input("Enter a number:"))

    b=int(input("Enter a number:"))

    c=a+b

    print("sum of 2 num is:",c)


#function calling

priya()


#function parameter with default value

def vish(a,b):

    c=a+b

    print("sum of 2 num is:",c)


#vish(12,7)


#function parameter with default value

#def p(x=2,y=4):

  #  c=x+y

   # print("sum is:",c)



#function parameter with default value

def p(x = 2, y=4):

    c = x+y

    return c


#out of function

print(" the sum of  2  num is ",p(5, 2))

print(" the sum of  2  num is ",p(15))

print(" the sum of  2  num is ",p())


Comments

Popular Posts