Search

# Write a Python Program to Find the Factorial of a Number?

Updated: Jun 23, 2020

Python Program to Find the Factorial of a Number num = int(input("Enter a number: ")) factorial = 1 # check if the number is negative, positive or zero if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num,"is",factorial)

Output:

Enter a number: 3 The factorial of 3 is 6

### Recent Posts

See All

#### Python Function Program without input argument and without return value

This type of function does not have input arguments but has a value to the main program. Write a program to generate the following pattern. 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 Program: def pattern(): for i

#### Python program without input argument and with return value

This type of function does not have input arguments but has a value to return to the main program. Write a program to calculate and print sum of first 50 even numbers. Program: def sum_even(): sum=0 f

#### Python Function Program with argument and without return value

This type of function has one or more input arguments but does not have any value to return to the main program. Write a program to input a number and print its table up to 10 terms. Program: def tabl

9555593818

Thakurdwara, Uttar Pradesh 244601, India