-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_calculator.py
More file actions
40 lines (26 loc) · 858 Bytes
/
Copy pathsimple_calculator.py
File metadata and controls
40 lines (26 loc) · 858 Bytes
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
'''
let's build a simple calculator with some basic logics
'''
print("select an operation")
print("1. Addition")
print("2. Subtraction")
print("3. Multiplication")
print("4. Division")
print() #for newline
choice = int(input("enter your choice: "))
num1 = float(input("enter the first number: "))
num2 = float(input("enter the second number: "))
if choice == 1:
print(num1, " + ", num2, " = ", num1+num2)
elif choice == 2:
print(num1, " - ", num2, " = ", num1 - num2)
elif choice == 3:
print(num1, " * ", num2, " = ", num1*num2)
elif choice == 4:
print(num1, " / ", num2, " = ", num1/num2)
else:
print("invalid choice, enter currect choice")
'''
great we have built a simple calculator which can perform addition, subtraction, multiplication and division
thank you for watching
'''