This repository contains two Python scripts developed as part of Module 4: Functions & Modules in Python.
File: task1_factorial.py
This script defines a recursive function factorial(number) that calculates the factorial of a given non-negative integer.
- Handles negative inputs by returning an error message.
- Uses recursion with a base case of factorial(0) = 1.
- Prints the factorial of a sample number (e.g., 5).
Example output: The factorial of 5 is: 120
File: task2_math_module.py
This script:
- Takes a number input from the user.
- Validates the input to ensure the square root and natural logarithm can be calculated.
- Calculates and displays:
- Square root of the number
- Natural logarithm (base e) of the number
- Sine of the number (in radians)
Example interaction: Enter the number: 25 Square root of 25.0 is: 5.0 Natural logarithm of 25.0 is: 3.2188758248682006 Sine of 25.0 radians is: -0.13235175009777303