This repository contains a straightforward, single-run command-line calculator program written in Python. It's designed as a beginner-friendly project to demonstrate fundamental arithmetic operations and basic user interaction in a console environment.
- Addition (
+): Adds two numbers. - Subtraction (
-): Subtracts the second number from the first. - Multiplication (
*): Multiplies two numbers. - Division (
/): Divides the first number by the second, with basic error handling for division by zero. - User-Friendly: Prompts the user for inputs and operation choice.
To run this calculator, you'll need Python installed on your computer.
- Python 3.x (Download and install the latest Python 3 version if you don't have it.)
-
Save the code:
- Save the calculator code (from our conversation) into a file named
my_calculator.py. Make sure it's in a folder you can easily find (e.g., your Desktop or a dedicatedgithub_projectsfolder).
- Save the calculator code (from our conversation) into a file named
-
Open your Command Prompt/Terminal:
- On Windows: Open File Explorer, go to the folder where you saved
my_calculator.py. Click in the address bar at the top, typecmd, and pressEnter. This will open Command Prompt directly in that folder. - On Mac/Linux: Open your Terminal application and use the
cdcommand to navigate to the directory where you saved the file. For example:cd ~/Desktoporcd /path/to/your/folder.
- On Windows: Open File Explorer, go to the folder where you saved
-
Run the Python script:
- Once you are in the correct folder in your Command Prompt/Terminal, type the following command and press
Enter:python my_calculator.py
- Once you are in the correct folder in your Command Prompt/Terminal, type the following command and press
-
Interact with the calculator:
- Follow the on-screen prompts to enter your numbers and choose an operation.
- The calculator will perform the calculation and display the result, then the program will exit.
This project is a basic learning exercise. Feel free to fork it, experiment with the code, and make improvements!
This project is open-source and available under the MIT License.