Skip to content
Closed
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
34 changes: 9 additions & 25 deletions calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

## Imported math library to run sin(), cos(), tan() and other such functions in the calculator

from fileinfo import raw_input


def calc(term):
"""
input: term of type str
Expand Down Expand Up @@ -76,18 +73,14 @@ def calc(term):
# here goes to the error cases.
except ZeroDivisionError:
print("Can't divide by 0. Please try again.")

except NameError:
print("Invalid input. Please try again")

except AttributeError:
print("Please check usage method and try again.")
except TypeError:
print("please enter inputs of correct datatype ")

print ("Please only enter integers")
return term


def result(term):
"""
input: term of type str
Expand All @@ -109,21 +102,12 @@ def main():
"\nScientific Calculator\n\nFor Example: sin(rad(90)) + 50% * (sqrt(16)) + round(1.42^2)"
+ "- 12mod3\n\nEnter quit to exit"
)

if sys.version_info.major >= 3:
while True:
k = input("\nWhat is ")
if k == "quit":
break
result(k)

else:
while True:
k = raw_input("\nWhat is ")
if k == "quit":
break
result(k)


if __name__ == "__main__":
k = input("\nWhat is ")
if k == "quit" or "q":
result(k)
elif k == None:
print("Couldn't read input. Please try again.")
elif q == None:
print("Couldn't read input. Please try again.")
else:
main()
3 changes: 3 additions & 0 deletions requirements_with_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ background==0.2.1
pydantic==2.12.3
openpyxl==3.1.2
pytesseract==0.3.13
pydantic==2.7.3
openpyxl==3.1.5
pytesseract==0.3.10
requests-mock==1.12.1
pyglet==2.1.9
urllib3==2.5.0
Expand Down
Loading