saving . . . saved syntax to find factorial of a number has been deleted. syntax to find factorial of a number has been hidden .
syntax to find factorial of a number
Question
Respected sir/mam, in the 2 question we got to know how to find the factorial of the numbers from 1 to 20 . could you please tell me  how to find the factorial of a particular  number say factorial of 10 i.e 10! ?

Python-3.4.3 Getting-started-with-for 09-10 min 50-60 sec 17-01-21, 8:12 p.m. shraddhakb1893@gmail.com

def factorial(n):
fact = 1
if n < 0:
return "Factorial does not exists for negative numbers"
elif num == 0:
return 1
else:
for i in range(1, n + 1):
fact =  fact * i
return fact

factorial(10)
15-03-21, 12:25 p.m. iakashchavan
Thanks a lot...
Traceback (most recent call last):
File "C:\python\factorial.py", line 12, in <module>
factorial(10)
File "C:\python\factorial.py", line 5, in factorial
elif num == 0:
NameError: name 'num' is not defined
it says this!

num=int(input('enter a number'))
fact=1
for i in range(1,num+1):
fact=fact*i
print ('factorial of', num, '=',fact)