GithubHelp home page GithubHelp logo

pycalc's Introduction

Standalone Calculator

A Python calculator project to enable to do any simple math express calculation.

Motivation

I decided to research a bit more complex scenario for my Python studies and I found this peculiar script, the script looks interesting but had some pitfalls, which is interesting for learning 😃 So I decided to take it as an exercise and also produce some interesting ideas for further scenarios to come.

Source

The code was originally developed in conjunction by internet_user and Gareth Rees on StackExchange.

This code has fixed some pitfalls:

  • can execute consecutive different operations in the same level (ex. 2 * 2 / 2 = 2)
  • can execute operations starting with + and - and also deal with small operations like (-10).

And also has some improvements:

  • accepts inputs with spaces and special characters [, ], {, }, , :, ÷, x, ² and ³.
  • some code reviews

How to Use

  1. Clone this repository.
  2. Execute main.py with an expression as arguments:
$ ./main.py 1 + 1

or

$ python main.py 1 + 1
  1. Follow the instructions: input the complete expression as arguments for the script. The result is displayed. (See Supported Operations)

Supported Operations

operator function
+ addition
- subtraction
* x multiplication
/ : ÷ division
^NUM exponentiation
² ³ shortcuts for exponentiation to 2 and 3

Requirements

pip3 install -r requirements.txt

or

pip install -r requirements.txt

License

Apache 2.0 license. See more details here.

pycalc's People

Contributors

jjbeto avatar

Watchers

James Cloos avatar  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.