How to program factorial in Python?

label Computer Science
account_circle Unassigned
schedule 1 Day
account_balance_wallet $5

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

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Nov 22nd, 2014
...
Nov 22nd, 2014
Jun 26th, 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