Overview
A simple console-based calculator written in Python — one of my earliest programming projects while learning the fundamentals of input handling, loops, type conversion, conditionals, and error checking.
This project was created to practice the basics of user interaction and validation, ensuring the program handles invalid input gracefully and performs basic arithmetic operations reliably.
It marked a key early step in learning structured thinking, error handling, and code design for reusability.
How It Works The program begins by prompting the user for two numbers. It validates input using a try/except block — if the user enters something that isn’t a number, it asks again until valid input is received. Once valid numbers are entered, the user selects an operator (+, -, *, /). Based on the operator: Performs the corresponding arithmetic operation. Handles division by zero gracefully, returning “Undefined”. After displaying the result, the program asks if the user wants to run another calculation or exit.
Features Addition, Subtraction, Multiplication, Division Error handling for invalid numeric input. Division by zero protection — safely avoids crashes. Continuous use — option to restart or exit after each operation. User-friendly text prompts with clear operator options.
Skills Demonstrated Python Fundamentals: loops, conditionals, user input, and function structure. Type Conversion & Validation: safely converting user input from strings to integers. Exception Handling: catching invalid input with try/except. Control Flow Design: nested loops for continuous use and restart options. Basic Program Structure: function-based logic with main loop and clean termination. User Interaction Design: readable prompts, feedback messages, and input sanitation.
Possible Improvements Support for floating-point numbers and advanced math functions (e.g., exponents, modulus). Add operation chaining (e.g., calculate result → use in next calculation). Convert into a GUI or CLI app with a menu or buttons using tkinter or argparse. Provide clearer error messages and validation feedback. Allow saving calculation history to a text file. Extend to scientific mode (square roots, trigonometry, etc.).