-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHW2
More file actions
75 lines (48 loc) · 1.08 KB
/
HW2
File metadata and controls
75 lines (48 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import sys
def greet_user():
"""Display a simple greeting."""
print("Hello Young Master!")
print("My name is Cal!")
greet_user()
print("I can be used for making mathematical calculations.")
print("Now, How may I be of assistance?")
while True:
# input choice
try:
print()
a=int(input("Enter First Number:"))
b=int(input("Enter Second Nunber:"))
except:
print("Error")
sys.exit(1)
print()
print("Calculator Operations")
print("1.Add")
print("2.Substract")
print("3.Multiply")
print("4.Divide")
print("5. Exit Program")
print()
try:
ch=int(input("Enter Choice(1-4): "))
except:
print("Error")
sys.exit(1)
if ch== 1:
c=a+b
print("Sum = ",c)
elif ch==2:
c=a-b
print("Difference = ",c)
elif ch==3:
c=a*b
print("Product = ",c)
elif ch==4:
c=a/b
print("Quotient = ",c)
elif ch==5:
#if ch==6:
g=str(input("Continue?"))
else: print("Invalid Choice")
else:
Break