GithubHelp home page GithubHelp logo

lamhoangtung / simple-calculator-using-reverse-polish-notation Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 201 KB

Simple Calculator using Reverse Polish Notation

License: MIT License

Jupyter Notebook 91.62% Python 8.38%
calculator polish-notation reverse-polish-notation expression-tree python3

simple-calculator-using-reverse-polish-notation's Introduction

Simple-Calculator-using-Reverse-Polish-Notation

Simple Calculator using Reverse Polish Notation in Python

How to run

When main.py is running, you will be able to input your expression, the program will evaluate your expression and also plot an Expression Tree to the console and to a .dot file:

alt text

It's also can handle one variable function, when evaluate the expression, the program will ask you to input the value of the variable:

alt text

You can use dot tool from the graphviz package to render the expression tree into a .png image:

dot tree.dot -T png -o tree.png

You can also copy all content inside the tree.dot file and use Webgprahviz to plot the tree right inside your browser:

If the expression is an one variable function, this program can plot it to a .png file. It will ask you the range of the graph and how many point (how acurrate) you want the graph to be. Keep in mind, you shoudn't plot with too little points since it may lead to wrong graph:

Dependencies

The code was developed with the following configuration:

  • python 3.6.4
  • anytree 2.4.3
  • graphviz 0.8.4
  • numpy 1.14.2
  • pandas 0.22.0
  • matplotlib 2.2.2

Other configuration will reasonably work

Documentation

You can see the details documentation about how I make this calculator in the [notebook file](Simple Calculator using Reverse Polish Notation.ipynb).

Contributing

Please feels free to contribute to this project, there are a lot of room for improvement, my suggestion are:

  • Evaluate expression using expression tree and DFS
  • Making UI (currently running on console)
  • Add support for more variable (currently support only one variable)
  • Add more operator (currently support + - * / ^ and sqrt)
  • Better method for plotting function

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

simple-calculator-using-reverse-polish-notation's People

Contributors

lamhoangtung avatar

Stargazers

 avatar  avatar

Watchers

 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.