Skip to content

SomilSodhi/python-cli-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

python-cli-calculator

A robust command-line calculator in Python featuring continuous input validation, exception handling, and zero-division protection.

Python CLI Calculator with Input Validation

📌 Project Overview

A robust, text-based interactive calculator built in Python. This project demonstrates foundational programming logic, control flow, and a strong emphasis on user experience by actively preventing program crashes caused by invalid data entry.

⚙️ Features

  • Input Validation: Utilizes while loops to ensure the program only accepts valid numbers and designated math operators.
  • Exception Handling: Implements try-except blocks to gracefully catch ValueError instances when a user inputs text or special characters instead of numbers.
  • Zero-Division Protection: Contains edge-case logic to prevent the program from crashing when a user attempts to divide by zero.
  • Flexible Operators: Recognizes multiple variations of standard operators (e.g., *, X, x for multiplication and /, ÷ for division).

🧠 Technical Concepts Demonstrated

Building this calculator allowed me to practice and apply several core Python concepts:

  • Type Casting: Converting string inputs into float data types for precise mathematical calculations.
  • Control Flow: Using if/elif/else statements to route the program's logic based on user input.
  • Infinite Loops & Break Statements: Managing application state to keep prompting the user until correct data is provided.

🚀 How to Run

  1. Ensure you have Python installed on your system.
  2. Clone this repository or download the calculator.py file.
  3. Run the following command in your terminal:
   python calculator.py

About

A robust command-line calculator in Python featuring continuous input validation, exception handling, and zero-division protection.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages