-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfuntions.py
More file actions
52 lines (37 loc) · 1.21 KB
/
funtions.py
File metadata and controls
52 lines (37 loc) · 1.21 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
45
46
47
48
49
50
51
52
def op(x,y,z):
if z == "+":
a = x + y
if z == "-":
a = x - y
if z == "*":
a = x * y
if z == "/":
a = x / y
return a
while True:
q = input("Do you want to do a calculation?y/n:")
while q not in ["y","n"]:
print("Enter only y or n.")
q = input("Enter only y or n only please:")
if q == "y":
x = input("Enter a number:")
while x.isdigit() == False:
print("Do not enter other characters than numbers.")
x = input("Enter a number only please:")
x = int(x)
y = ("Enter a number:")
while y.isdigit() == False :
print("Do not enter other characters than numbers.")
y = input("Enter a number only please:")
y = int(y)
z = input("Enter an operator:")
while z not in ["+","-",'*',"/"]:
print("Do not enter other characters than numbers.")
z = input("Enter an operator only please:")
if y == 0 and z == "/":
print("Zero division error")
break
print(op(x,y,z))
if q == "n":
exit
#0 div