GithubHelp home page GithubHelp logo

simple-calculator's Introduction

Simple Calculator

This is a simple calculator that can perform basic arithmetic operations.

Usage

To use the calculator, run the simple_calculator function. The calculator will prompt the user to enter two numbers and an operator, and will then perform the specified operation on the numbers. The following operators are supported:

  1. +: addition
  2. -: subtraction
  3. *: multiplication
  4. /: division

The calculator will continue to run until the user inputs None for one of the numbers or the operator.

Validation

The calculator includes several validation checks to ensure that the input is valid. The is_number function is used to validate that the input is a number, and the is_valid_operator function is used to validate that the input is a supported operator. If the input is not valid, the user will be prompted to try again.

Error Handling

The calculator also includes error handling for division by zero errors. If the user attempts to divide by zero, the calculator will display an error message and return None as the result.

Testing

The calculator includes a test suite in the tests.py file. To run the tests, simply run the unittest module on the Tester class. The tests cover all of the main functionality of the calculator, including validation and error handling.

Dependencies

The calculator relies on the re module for input validation. This module is part of the Python standard library and does not need to be installed separately.

simple-calculator's People

Contributors

abenteuerzeit avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.