Site icon DataFlair

Functions in Python

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

#Program of Functions in Python
# 
def factorial(): #
    f=1
    n=int(input("Enter a number"))
    while(n!=0):
        f=f*n
        n=n-1
    print("Factorial is: ",f)        



# Main 
#factorial()  #calling

Program 2

# import TestFunction1 as tf
# tf.factorial()
def first():
    print("One")
    second()
    print("Two")

def second():
    print("Three")
    Third()
    print("four")

def Third():
    print("Five")    

# Main
print("Main Code Starts")
first()
print("Main Code Ends")

 

Exit mobile version