-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathcalculator.py
More file actions
44 lines (35 loc) · 1.05 KB
/
calculator.py
File metadata and controls
44 lines (35 loc) · 1.05 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
choice = input("""
Please select the type of operation you want to perform:
+ for addition
- for subtraction
* for multiplication
/ for division
** for exponentiation
// for floor division
% for Modulus
""")
num_1 = int(input("Enter your first number: "))
num_2 = int(input("Enter your second number: "))
if choice == "+":
print("{} + {} = ".format(num_1, num_2))
print(num_1 + num_2)
elif choice == "-":
print("{} - {} = ".format(num_1, num_2))
print(num_1 - num_2)
elif choice == "*":
print("{} * {} = ".format(num_1, num_2))
print(num_1 * num_2)
elif choice == "/":
print("{} / {} = ".format(num_1, num_2))
print(num_1 / num_2)
elif choice == "**":
print("{} ** {} = ".format(num_1, num_2))
print(num_1 ** num_2)
elif choice == "//":
print("{} // {} = ".format(num_1, num_2))
print(num_1 // num_2)
elif choice == "%":
print("{} % {} = ".format(num_1, num_2))
print(num_1 % num_2)
else:
print("Enter a valid operator, please run the program again.")