hi little if may assist in way.
i have data sets
name, age, mark, 19, john, 19, jess, 25, jonty, 21,
i run calculation compares distance work data
distance work(km) 20 25 30 40
what want associate these each name. do using list or class structure thing?? output want.
mark, 19, 20 john, 19, 25 jess, 25, 30 jonty, 21, 40
secondly want know possible compare these values , make average lets have maxdist = 35
can written compare these dist max distance , take values appear.
mark, 19, 20 john, 19, 25 jess, 25, 30
and calculate average age?? i.e 21??
assuming they're in same order, crude - classes overkill:
>>> people = [ ... ('mark', 19,) , ... ('john', 19, ), ... ('jess', 25, ), ... ('jonty', 21,)] >>> >>> to_work = map(int, '20 25 30 40'.split()) >>> result = [] >>> ages = [] >>> index, person in enumerate(people): ... name, age = person ... result.append((name, age, to_work[index])) ... ages.append(age) ... >>> print '\n'.join(map(str, result)) ('mark', 19, 20) ('john', 19, 25) ('jess', 25, 30) ('jonty', 21, 40) >>> print 'max dist =', max(to_work) max dist = 40 >>> print 'avg. age =', sum(ages) / len(ages) avg. age = 21
Comments
Post a Comment