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")

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply