This Python calculator script is a powerful tool that supports a wide range of mathematical operations. It includes basic arithmetic calculations, advanced mathematical functions, matrix operations, polynomial calculations, integration, differentiation, statistical analysis, and function plotting. This README provides a detailed guide on the usage, features, and code structure of the calculator.
-
Basic Arithmetic Operations
- Addition
- Subtraction
- Multiplication
- Division
- Exponentiation
-
Advanced Mathematical Functions
- Square Root
- Factorial
- Trigonometric Functions (sin, cos, tan, asin, acos, atan)
-
Matrix Operations
- Addition
- Subtraction
- Multiplication
- Determinant Calculation
- Matrix Inversion
- Eigenvalues Calculation
-
Polynomial Operations
- Evaluation of Polynomials
- Finding Roots of Polynomials
-
Integration and Differentiation
- Definite Integration of Functions
- Differentiation of Functions
-
Statistical Analysis
- Mean
- Median
- Variance
- Standard Deviation
-
Function Plotting
- Visualize Functions Using Matplotlib
To run this script, you need Python and several Python libraries installed:
numpy
scipy
matplotlib
Install these libraries using pip:
pip install numpy scipy matplotlib
git clone https://github.com/mdriyadkhan585/Advanced_calculator
cd Advanced_calculator
-
Run the Script: Execute the script in your Python environment.
python simple-calculator.py python level-calculator.py python next-level-calculator.py python advanced-calculator.py python pro-calculator.py
-
Select an Operation: Choose from the operations listed in the menu.
-
Provide Inputs: Follow the prompts to enter the required values.
-
View Results: The results will be displayed based on the operation chosen.
- Addition:
add(x, y)
- Returns the sum ofx
andy
. - Subtraction:
subtract(x, y)
- Returns the difference betweenx
andy
. - Multiplication:
multiply(x, y)
- Returns the product ofx
andy
. - Division:
divide(x, y)
- Returns the quotient ofx
divided byy
, handling division by zero. - Exponentiation:
exponent(x, y)
- Returnsx
raised to the power ofy
.
- Square Root:
square_root(x)
- Computes the square root ofx
, with error handling for negative inputs. - Factorial:
factorial(x)
- Computes the factorial ofx
, with validation for non-integer and negative inputs. - Trigonometric Functions:
trig_sin(x)
- Returns the sine of anglex
(in degrees).trig_cos(x)
- Returns the cosine of anglex
(in degrees).trig_tan(x)
- Returns the tangent of anglex
(in degrees).trig_asin(x)
- Returns the arc sine ofx
(domain: [-1, 1]).trig_acos(x)
- Returns the arc cosine ofx
(domain: [-1, 1]).trig_atan(x)
- Returns the arc tangent ofx
.
- Addition:
matrix_operations()
- Adds two 2x2 matrices. - Subtraction:
matrix_operations()
- Subtracts one 2x2 matrix from another. - Multiplication:
matrix_operations()
- Multiplies two 2x2 matrices. - Determinant Calculation:
matrix_operations()
- Computes the determinant of a 2x2 matrix. - Matrix Inversion:
matrix_operations()
- Computes the inverse of a 2x2 matrix, with error handling for singular matrices. - Eigenvalues Calculation:
matrix_operations()
- Finds the eigenvalues of a 2x2 matrix.
- Evaluation:
polynomial_operations()
- Evaluates a polynomial at a given value ofx
. - Finding Roots:
polynomial_operations()
- Finds the roots of a polynomial using its coefficients.
- Integration:
function_integration()
- Computes the definite integral of a user-defined function over a specified interval. - Differentiation:
function_differentiation()
- Computes the derivative of a user-defined function.
- Mean:
statistical_operations()
- Calculates the mean of a dataset. - Median:
statistical_operations()
- Calculates the median of a dataset. - Variance:
statistical_operations()
- Calculates the variance of a dataset. - Standard Deviation:
statistical_operations()
- Calculates the standard deviation of a dataset.
- Plotting:
plot_function()
- Plots a user-defined mathematical function over a specified range.
- Function Definitions: Contains functions for all the operations mentioned.
- Menu System: Provides an interactive menu for users to select operations.
- Input Handling: Prompts the user for inputs and processes them accordingly.
- Error Handling: Includes error handling for invalid inputs and mathematical errors.
- Plotting: Uses
matplotlib
to generate plots for visual representation of functions.
- Run the script using
python calculator.py
. - Choose an Operation: For example, select
1
for addition. - Enter Numbers: Provide two numbers when prompted.
- View Results: The result of the addition will be displayed.
Contributions are welcome! If you have suggestions for new features or improvements, please open an issue or submit a pull request.
- NumPy: For numerical computations.
- SciPy: For scientific and technical computing.
- Matplotlib: For plotting and visualization.
- Installation: Ensure that
numpy
,scipy
, andmatplotlib
are installed in your Python environment. - Running the Script: Save the Python code in a file named
calculator.py
and execute it. - Using the Calculator: Follow the interactive prompts to perform various mathematical operations.