There are many ways to calculate factorial in Python:-
The first thing you can do is as follows:-
def factorial(n):
return reduce(lambda x,y:x*y,[1]+range(1,n+1))
Another way would be as follows:-
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
To know more about this you can have a look at the following video tutorial:-