Skip to content

Commit 97e8791

Browse files
committed
Fixed stuff.
1 parent 8bf49de commit 97e8791

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

calculator.py

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727

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

30-
from fileinfo import raw_input
31-
32-
3330
def calc(term):
3431
"""
3532
input: term of type str
@@ -76,18 +73,14 @@ def calc(term):
7673
# here goes to the error cases.
7774
except ZeroDivisionError:
7875
print("Can't divide by 0. Please try again.")
79-
8076
except NameError:
8177
print("Invalid input. Please try again")
82-
8378
except AttributeError:
8479
print("Please check usage method and try again.")
8580
except TypeError:
86-
print("please enter inputs of correct datatype ")
87-
81+
print ("Please only enter integers")
8882
return term
8983

90-
9184
def result(term):
9285
"""
9386
input: term of type str
@@ -109,21 +102,12 @@ def main():
109102
"\nScientific Calculator\n\nFor Example: sin(rad(90)) + 50% * (sqrt(16)) + round(1.42^2)"
110103
+ "- 12mod3\n\nEnter quit to exit"
111104
)
112-
113-
if sys.version_info.major >= 3:
114-
while True:
115-
k = input("\nWhat is ")
116-
if k == "quit":
117-
break
118-
result(k)
119-
120-
else:
121-
while True:
122-
k = raw_input("\nWhat is ")
123-
if k == "quit":
124-
break
125-
result(k)
126-
127-
128-
if __name__ == "__main__":
105+
k = input("\nWhat is ")
106+
if k == "quit" or "q":
107+
result(k)
108+
elif k == None:
109+
print("Couldn't read input. Please try again.")
110+
elif q == None:
111+
print("Couldn't read input. Please try again.")
112+
else:
129113
main()

0 commit comments

Comments
 (0)