To calculate the factorial of a number in Python, you can use a loop to multiply the number by all of its positive integers less than itself.
Here's an example code:
num = 5
factorial = 1
for i in range(1, num + 1):
factorial = factorial * i
print("The factorial of", num, "is", factorial)
In this example, the variable num is set to 5, which is the number whose factorial we want to calculate. The variable factorial is initially set to 1, which is the starting value for the multiplication loop. The loop iterates over all positive integers less than or equal to num, multiplying them together to calculate the factorial. The result is then printed using the print function.
You can replace the value of num with any other positive integer to calculate its factorial using the same code. Note that the factorial function grows very quickly, and larger inputs may cause the program to take a long time or even crash due to the limitations of integer precision.