1+ import math
2+ while True :
3+ print ("""
4+ Press 1 for basic calculator
5+ Press 2 for scientifc calculator""" )
6+ try :
7+ cho = int (input ("enter your choice here.. " ))
8+ if cho == 1 :
9+ print (eval (input ("enter the numbers with operator " )))
10+ elif cho == 2 :
11+ user = int (input ("""
12+ Press 1 for pi calculation
13+ press 2 for sin calculation
14+ press 3 for exponent calculation
15+ press 4 for tangent calculation
16+ press 5 for square root calculation
17+ press 6 round calculation
18+ press 7 for absoulte value
19+ press any other number to exit the loop. """ ))
20+
21+ a = float (input ("enter your value here.. " ))
22+ if user == 1 :
23+ print (f"entered value : { a } result :{ math .pi * (a )} " )
24+ elif user == 2 :
25+ print (f"entered value : { a } result :{ math .sin (math .radians (a ))} " )
26+
27+ elif user == 3 :
28+ power = float (input ("enter the power" ))
29+ print (f"entered value : { a } result :{ a ** power } " )
30+ elif user == 4 :
31+ angle_in_radians = math .radians (a )
32+ result = math .tan (angle_in_radians )
33+ print (f"entered value : { a } result :{ result } " )
34+ elif user == 5 :
35+ print (f"entered value : { a } result :{ math .sqrt (a )} " )
36+ elif user == 6 :
37+ print (f"entered value : { a } result :{ round (a )} " )
38+ elif user == 7 :
39+ print (f"entered value : { a } result :{ abs (a )} " )
40+ else :
41+ break
42+ except ZeroDivisionError :
43+ print ("value cannot be divided by 0" )
44+ except :
45+ print ("Enter only digits " )
0 commit comments