-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCalculator.py
32 lines (16 loc) · 872 Bytes
/
Calculator.py
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
def calculator(x, y, ops):
if ops == "+": ## ---> if not in "+-*/" ---> Direkt bu kod ile kontrol edilebilirdi.
return(str(x) + " " + ops + " " + str(y) + " " + "=" + " " + str(x+y))
elif ops == "-":
return(str(x) + " " + ops + " " + str(y) + " " + "=" + " " + str(x-y))
elif ops == "/":
return(str(x) + " " + ops + " " + str(y) + " " + "=" + " " + str(x/y))
elif ops == "*":
return(str(x) + " " + ops + " " + str(y) + " " + "=" + " " + str(x*y))
else:
print("Please type one these items +, -, *, /")
while True:
x = int(input("Please type the first number: "))
y = int(input("Please type the second number: "))
ops = input("Choose between +, -, /, * ")
print(calculator(x,y,ops))