I have a series of attributes from different tables that I need to check against. In total there are about 40 items, like
origin, age, amount, etc
I have not really figured out the best way to collect data yet, maybe pull the data from the different sources and create a dict
i created a function for each test.
def age(value):
if value < 3:
Score = 1
elif 3 <= value < 5:
Score = 7
elif value >= 5:
Score = 10
else:
Score = 10
Weight = 5
return (Score, Weight)
def origin(value):
if value.upper() == "USA":
Score = 1
elif value.upper() == "JAPAN":
Score = 1
elif value.upper() == "CHINA":
Score = 10
elif value.upper() == "OTHER":
Score = 7
else:
Score = 10
Weight = 1
return (Score, Weight)
I take the values and append to a list
[[(7, 1)], [(1, 1)]]...
then
## calling all 40 functions doesnt seem efficient
lst.append([age(4)])
lst.append([origin("JAPAN")])
score = [item[0][0] for item in lst]
weight = [item[0][1] for item in lst]
scoresum = (listsum(score))
weightsum = (listsum(weight))
total = scoresum/weightsum
Does anyone know a better way to accomplish? I dont know, but it seems there has to be a better way