A versatile command-line calculator written in Python, offering a variety of mathematical operations from basic arithmetic to trigonometric functions and line equations.
- Arithmetic: Addition, subtraction, multiplication, division (needs improvement in current v1.6 code).
- Advanced Math: Square roots, cube roots, exponents, factorials, logarithms, absolute value, floor division.
- Geometry: Area (square, triangle), perimeter, triangle angles, line equations (slope and intercept), sine calculation.
- Unit Conversions: Fraction to decimal conversion.
- User Interaction: Interactive command-line interface with friendly prompts and robust error handling for inputs.
This is a pure Python application and requires a Python interpreter (Python 3.x recommended) installed on your system.
-
Save the Code: Copy the entire Python source code into a file named
calculator.py. -
Open Terminal/Command Prompt: Navigate to the directory where you saved
calculator.py. -
Execute the Script: Run the following command:
python calculator.py # or if you have multiple versions of python installed: python3 calculator.py
When you run the script, the calculator will greet you and ask for your name. It will then present a menu of 15 different operations you can choose from by entering the corresponding number.
The program uses a loop so you can perform multiple calculations in one session by answering "Y" when prompted "Wanna use this program again? (Y/N)".