This repository contains two Python programs that demonstrate the use of functions and modules:
- Task 1: Calculate Factorial Using a Function
- Task 2: Using the Math Module for Calculations
Each program takes user input, performs computations, and displays the expected output.
Filename: Task1.py
This program calculates the factorial of a given number using a recursive function. It takes an integer input from the user, computes the factorial, and displays the result.
- Run the script and enter an integer when prompted.
- The program will return and display the factorial of the entered number.
Enter a number: 5
Factorial of 5 is: 120Filename: Task2.py
This program demonstrates the use of Python’s built-in math module to perform mathematical calculations. It takes a numerical input from the user and computes:
- The square root of the number.
- The logarithm.
- The sine.
- Run the script and enter a number when prompted.
- The program will display the calculated results for square root, logarithm, and sine.
Enter a number: 25
Square root : 5.0
logarithm : 3.2188758248682006
Sine : -0.13235175009777303-
Ensure Python 3.x is installed on your system.
-
Clone this repository or download the files.
-
Open a terminal/command prompt and navigate to the directory where the files are located.
-
Run the programs using the following commands:
- For Task 1:
python Task1.py - For Task 2:
python Task2.py
- For Task 1:
- Python 3.x
- No external libraries required (uses built-in
mathmodule for Task 2).
Contributions and improvements are welcome! Feel free to modify the code and experiment with different approaches.
This project is open-source and free to use.