-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculater.py
More file actions
49 lines (41 loc) · 1.06 KB
/
Copy pathcalculater.py
File metadata and controls
49 lines (41 loc) · 1.06 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
class calculater:
def __init__(self,num1, num2,choice):
self.num1 = num1
self.num2 = num2
self.choice= choice
def add(self):
return self.num1 + self.num2
def subtract(self):
return self.num1 - self.num2
def multiply(self):
return self.num1 * self.num2
def divide(self):
if self.num2 != 0:
return self.num1 / self.num2
else:
return "numbers cannot divide by ZERO"
def main():
num1 = int(input("Enter your number_1: "))
num2 = int(input("Enter your number_2: "))
while True:
print("\n1. +")
print("2. -")
print("3. *")
print("4. /")
print("5. Exit")
choice = input("Enter your choice: ")
if choice =="1":
print(num1+num2)
elif choice=="2":
print(num1-num2)
elif choice=="3":
print(num1*num2)
elif choice=="4":
print(num1/num2)
elif choice == "5":
print("thank you")
break
else:
("invalid opr...")
if __name__ == "__main__":
main()