Programming Examples

Python program to create a function to calculate factorial value


Write a Python program to create a function for factorial value

Solution

def factorial(num):
    fact=1
    while(num>0):
        fact=fact*num
        num=num-1
    return(fact)
num=int(input("Enter any Number : "))
f=factorial(num)
print("Factorial value of ",num," is : ",f)
Output

Enter any Number : 5

Factorial value of  5  is :  120

CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online Exam Quiz O Level NIELIT Study material and Quiz Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Best Website and Software Company in Allahabad Website development Company in Allahabad