Skip to content

Commit d4d1800

Browse files
authored
Create SimpleCalculator.py
1 parent f57212b commit d4d1800

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

SimpleCalculator.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
A simple python calculator
3+
"""
4+
def initial_values():
5+
print("Enter a value")
6+
a = int(input())
7+
print("Enter another value")
8+
b = int(input())
9+
print(f"The values you entered are {a} and {b}")
10+
print("Please enter the type of operation you would like to perform \n for example '+' denotes the addition operation")
11+
global op
12+
op = input()
13+
try:
14+
print(eval(f"a {op} b"))
15+
except:
16+
print("🚫 An error has occured, please run program again 🚫")
17+
18+
19+
initial_values()

0 commit comments

Comments
 (0)