Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculator #1

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
calculator
calculator in python
==========

Calculator implemented in Python
Calculator implemented in Python
This calculator is created in python.Through which you will learn the bacis of the operators, if else and many things.

Not only the bacis but you will be learning the ERROR HANDLING, OOPs, and many more.
the best thing about this calculator is that you only have to give the expression which means that not only calculation between two numbers but you can give as much as operators and operands as you want to give as a input
7 changes: 5 additions & 2 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def printTokens(tokens):
expressions = ''
while iterator != len(tokens):
if tokens[iterator].getType() == TokenType.NUMBER_TOKEN:
print "Number:\t\t",
print "The Number = \t\t",
print tokens[iterator].getValue()
expressions += str(tokens[iterator].getValue()) + ' '
elif tokens[iterator].getType() == TokenType.OPERATOR_TOKEN:
Expand Down Expand Up @@ -62,4 +62,7 @@ def main():


if __name__ == '__main__':
main()
try:
main()
except Exception as e:
pass
7 changes: 5 additions & 2 deletions scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
#Comp 141, Homework 7
#Python Calculator (calculator.py)

from calcExceptions import CalcExceptions
import token
try:
from calcExceptions import CalcExceptions
import token
except Exception as e:
pass

#Scanner Class
#Takes in user input and splits into tokens
Expand Down