-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHw#2 Update
More file actions
72 lines (51 loc) · 1.2 KB
/
Hw#2 Update
File metadata and controls
72 lines (51 loc) · 1.2 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
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=float(input("Enter the first number:"))
b=float(input("Enter the second nunber:"))
except:
print("Error")
sys.exit(1)
# print()
# print("Calculator Operations")
# print("+.Add")
# print("-.Substract")
# print("*.Multiply")
# print("/.Divide")
# print("**.Exponential")
# print()
try:
ch=input("Enter the operation: ")
except:
print("Error")
sys.exit(1)
if ch=="+":
c=a+b
print("Sum = ",c)
elif ch=="-":
c=a-b
print("Difference = ",c)
elif ch=="*":
c=a*b
print("Product = ",c)
elif ch=="/":
c=a/b
print("Quotient = ",c)
elif ch == "**":
c = a ** b
print("Exponential = ", c)
else: print("Invalid Choice")
User = input("Do you wish to exit?")
if User == "n":
continue
elif User == "y":
break