Data Validation. in PYTHON
Programe is:
#
# Data validation
# x is a positive number
# y is the number in a set set SET
# z is a number in a range (a; b)
# w is less than A
# v is a number greater than A
# Function ispositive (x) return True if x is positive
# Function isinset (y) return True if y is a member in SET
# Function isinrange (z, a, b) return True if z <b and a <z
# Function isless (w, A) return True if w <A
# Function isgreather (v, B) return True if B <v
def ispositive(x):
Beta = x.isdigit()
if Beta == True:
Gama = float(x)
else:
return False
if Gama > 0:
return True
else:
return false
X1 = '10'
print(ispositive(X1))
X2 = '-10'
print(ispositive(X2))
#
# y is in set
#
def isinset(y, SET):
Alfa = False
for i in SET:
if i == y:
Alfa = True
return Alfa
SET_1 = {1, 2, 3,4,5,6,7, 8, 9, 10}
Y1 = 7
print(isinset(Y1, SET_1))
Y2 = 100
print(isinset(Y2, SET_1))
#
# z is in range
#
def isinrange(z, a, b):
if z > a and z < b:
Gama = True
else:
Gama = False
return Gama
Z1 = 5
A = 1
B = 10
Z2 =-10
Z3 = 100
print(isinrange(Z1, A, B))
print(isinrange(Z2, A, B))
print(isinrange(Z3, A, B))
#
# w < A
#
def islessthan(w, A):
Gama = False
if w < A:
Gama = True
return Gama
W1 = 15
W2 = 100
A = 20
print(islessthan(W1, A))
print(islessthan(W2, A))
#
# v > B
#
def isgreatherthan(v, B):
Gama = False
if v > B:
Gama = True
return Gama
V1 = 20
V2 = 5
B = 10
print(isgreatherthan(V1, B))
print(isgreatherthan(V2, B))
results are:
============== RESTART: /Users/ionivan/Documents/DataValidation.py =============
True
False
True
False
True
False
False
True
False
True
False
#
# Data validation
# x is a positive number
# y is the number in a set set SET
# z is a number in a range (a; b)
# w is less than A
# v is a number greater than A
# Function ispositive (x) return True if x is positive
# Function isinset (y) return True if y is a member in SET
# Function isinrange (z, a, b) return True if z <b and a <z
# Function isless (w, A) return True if w <A
# Function isgreather (v, B) return True if B <v
def ispositive(x):
Beta = x.isdigit()
if Beta == True:
Gama = float(x)
else:
return False
if Gama > 0:
return True
else:
return false
X1 = '10'
print(ispositive(X1))
X2 = '-10'
print(ispositive(X2))
#
# y is in set
#
def isinset(y, SET):
Alfa = False
for i in SET:
if i == y:
Alfa = True
return Alfa
SET_1 = {1, 2, 3,4,5,6,7, 8, 9, 10}
Y1 = 7
print(isinset(Y1, SET_1))
Y2 = 100
print(isinset(Y2, SET_1))
#
# z is in range
#
def isinrange(z, a, b):
if z > a and z < b:
Gama = True
else:
Gama = False
return Gama
Z1 = 5
A = 1
B = 10
Z2 =-10
Z3 = 100
print(isinrange(Z1, A, B))
print(isinrange(Z2, A, B))
print(isinrange(Z3, A, B))
#
# w < A
#
def islessthan(w, A):
Gama = False
if w < A:
Gama = True
return Gama
W1 = 15
W2 = 100
A = 20
print(islessthan(W1, A))
print(islessthan(W2, A))
#
# v > B
#
def isgreatherthan(v, B):
Gama = False
if v > B:
Gama = True
return Gama
V1 = 20
V2 = 5
B = 10
print(isgreatherthan(V1, B))
print(isgreatherthan(V2, B))
results are:
============== RESTART: /Users/ionivan/Documents/DataValidation.py =============
True
False
True
False
True
False
False
True
False
True
False
(April 04,2022)
Comments
Post a Comment