Ch 38 def function and function making process

 def add_two (a,b): #in python define we use def keyword to define a funtion

return a+b #return funtion can return what u do funtion for task

total=add_two(5,4) #if u want to print thr result u must store in variable u can use shrtcut for this

print(total)  #print






#u can also use this to short your program

def add_two(a,b):

return a+b

print(add_two(9,1))





#for def input

def add_two(num1,num2):

return num1+num2

a=int(input("enter your first number"))

b =int(input("enter your second number"))

total=add_two(a,b)

print(total)






#for def input to add string to string

def add_two(num1,num2):

return num1+num2

a=input("enter your first name")

b =input("enter your last name")

total=add_two(a,b)

print(total)

Comments