-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidation.py
More file actions
40 lines (32 loc) · 1.12 KB
/
validation.py
File metadata and controls
40 lines (32 loc) · 1.12 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
import modules as mod
def checkequalsign(equation) :
found = False
equation = equation.replace(" ","")
for i in range(len(equation)) :
if equation[i] == "=" :
found = True
return found
def checknumberafterequal(equation) :
equation = equation.replace(" ","")
if equation[len(equation)-1] == "=" :
return False
else:
return True
def checkoperator(equation) :
found = False
indexofoperators = []
equation = mod.standardform(equation)
equation = equation[0:mod.findindexofthecomponent(equation,"=")]
for i in range(len(equation)) :
if equation[i] == "/" : # 1 -2X/-8=10 # 2 -8/-2X=10 # 1 -2X-8=10 # 2 -8-2X=10
found = True
elif equation[i] == "x" :
found = True
if found == False :
for x in range(len(equation)) :
if equation[x] == "+" or equation[x] == "-" :
indexofoperators.append(x)
if found == False and len(indexofoperators) == 0 :
return False
else :
return True