Tuesday, June 23, 2020
python Function with Return Statement
def add(a,b):
return(a+b)
def sub(a,b):
return(a-b)
def factorial(a):
f=1
for i in range(1,a+1):
f=f*i
return(f)
c=add(9,7)+sub(7,5)+factorial(7)+sub(9,5)+add(3,4)+len("india")
print(c)
Python Function with example
def add(a,b):
print(a+b)
def sub(a,b):
print(a-b)
def factorial(a):
f=1
for i in range(1,a):
f=f*i
print(f)
x=add(5,4)
y=sub(9,8)
z=factorial(5)
print(x,y,z)
Subscribe to:
Posts (Atom)