-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmini project.py
More file actions
33 lines (28 loc) · 1.02 KB
/
mini project.py
File metadata and controls
33 lines (28 loc) · 1.02 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
# mini project time
# mini calculator
run = True
while run:
print("Select operation.")
print("1.Addittion")
print("2.Subtraction")
print("3.Multiplication")
print("4.Division")
print("5.Exit")
choice = input("Enter choice(1/2/3/4/5): ")
if choice in ['1', '2', '3', '4']:
num1 = float(input("Enter first number: "))
num2 = float(input("Enter second number: "))
if choice == '1':
print("result:", num1, "+", num2, "=", num1 + num2)
elif choice == '2':
print("result:", num1, "-", num2, "=", num1 - num2)
elif choice == '3':
print("result:", num1, "*", num2, "=", num1 * num2)
elif choice == '4':
if num2 != 0: # !! means not in python
print("result:", num1, "/", num2, "=", num1 / num2)
else:
print("Error: Division by zero is not allowed.")
elif choice == '5':
run = False
print("Exiting the calculator. Goodbye!")