File tree Expand file tree Collapse file tree 1 file changed +9
-25
lines changed Expand file tree Collapse file tree 1 file changed +9
-25
lines changed Original file line number Diff line number Diff line change 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-
3330def 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-
9184def result (term ):
9285 """
9386 input: term of type str
@@ -109,21 +102,12 @@ def main():
109102 "\n Scientific Calculator\n \n For Example: sin(rad(90)) + 50% * (sqrt(16)) + round(1.42^2)"
110103 + "- 12mod3\n \n Enter quit to exit"
111104 )
112-
113- if sys .version_info .major >= 3 :
114- while True :
115- k = input ("\n What is " )
116- if k == "quit" :
117- break
118- result (k )
119-
120- else :
121- while True :
122- k = raw_input ("\n What is " )
123- if k == "quit" :
124- break
125- result (k )
126-
127-
128- if __name__ == "__main__" :
105+ k = input ("\n What 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 ()
You can’t perform that action at this time.
0 commit comments