make me a simple python program with documentation
- User
make me a simple python program with documentation
Assistant
# Simple Python Program with Documentation # This program calculates and prints the factorial of a given number. def factorial(number): """ Calculate the factorial of a given number. Args: number (int): A non-negative integer whose factorial is to be calculated. Returns: int: The factorial of the provided number. """ # Base case: factorial of 0 is 1 if number == 0: return 1 # Recursive case: n! = n * (n-1)! else: return number * factorial(number - 1) # Example usage: if __name__ == "__main__": num = 5 print(f"The factorial of {num} is {factorial(num)}")
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.