How to program factorial in Python?

Computer Science
Tutor: None Selected Time limit: 1 Day

I don't get it :(((
Nov 22nd, 2014

# Python program to find the

# factorial of a number

# provided by the user

# take input from the user

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)

Reference:

http://www.programiz.com/python-programming/examples/factorial


Nov 22nd, 2014

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 22nd, 2014
...
Nov 22nd, 2014
Mar 24th, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer