Answer:
def factorial(n):
 if n == 0:
 return 1
 else:
 return n * factorial(n - 1)
# Example usage:
num = 5
result = factorial(num)
print(f"The factorial of {num} is: {result}")
Step-by-step explanation:
Certainly! Here's a simple example of Python code that calculates the factorial of a number using a recursive function:
```python
def factorial(n):
 if n == 0:
 return 1
 else:
 return n * factorial(n - 1)
# Example usage:
num = 5
result = factorial(num)
print(f"The factorial of {num} is: {result}")
```
In this example, the `factorial()` function takes an input `n` and recursively calculates the factorial of `n`. The base case is when `n` equals 0, in which case the function returns 1. Otherwise, it multiplies `n` by the factorial of `n-1`.
The code then uses the `factorial()` function to calculate the factorial of `num` (in this case, 5) and stores the result in the `result` variable. Finally, it prints the result to the console.
When you run this code, it will output:
```
The factorial of 5 is: 120
```
This is just a simple example, but Python is a versatile language capable of much more complex tasks. Let me know if there's anything specific you'd like to see an example of!