I have this function that takes info from two lists, and produces a list that shows their values in ... non interger form (0.8). I'm calling this function in a for loop, and this function gets repeated 20 times, pulling different info each time. This function works just fine, and does exactly what I want it to do.

def percentage(student_marks, total_quiz_marks):
quiz_precentage = []
for position in range(len(student_marks)):
quiz_precentage.append(float(student_marks[position]) / float(total_quiz_marks[position]))
return quiz_precentage

However... I need to take the info generated by this function, and pull out the lowest mark from each of these lists that is generated. I'v tried doing that with a different function, and get nothing but errors. I've tried several different ways, and was wondering if someone would be able to help out.

I'm not really sure if I understood you correctly, but maybe, this is what you want?

def percentage(student_marks, total_quiz_marks):
	
	quiz_precentage = []
	stud_marks_min = student_marks[0];
	tot_q_marks_min = total_quiz_marks[0]
	
	for position in range(len(student_marks)):
		
		quiz_precentage.append(float(student_marks[position]) / float(total_quiz_marks[position]))
		
		if stud_marks_min > student_marks[position]:
			stud_marks_min = student_marks[position]
		if tot_q_marks_min > total_quiz_marks[position]:
			tot_q_marks_min = total_quiz_marks[position]
			
	return ( quiz_precentage, stud_marks_min, tot_q_marks_min )

Hi!

I'm also not really sure what you want, but to get the minimum of a list you can do what Micko showed, or just (a little shorter ;))

minimum = min(student_marks)

Regards, mawe

Maybe, but I don't think either of those will work. The lists (20) that are outputed, each contain 6 items. And I need to pull out the smallest of those marks, in each of the 20 lists that are outputed. I belive that it would have to be inside a for loop. The 2 lists that I'm taking the info from, student_marks, and total_quiz_marks, has the individual grades, and the total mark the quiz is out of (they are all different). I divide those, then I need to pull out the lowest one.

Anyway, what you gave me, gives me a new angle. Thanks.

Maybe like this?

return quiz_percentage, min(quiz_percentage)

If that's still not what you want (and I guess it is :)), could you show some input and the output you expect?

Well it's rather messy, but it works. I just wanted to thank you micko, and mawe for helping me out. Hey, one last question.... how do you guys make your funky code thing show up like you do?

code:
def percentage(student_marks, total_quiz_marks):
quiz_precentage = []
for position in range(len(student_marks)): quiz_precentage.append(float(student_marks[position]) / float(total_quiz_marks[position]))
if min(quiz_precentage) == quiz_precentage[0]:
del quiz_precentage[0]
elif min(quiz_precentage) == quiz_precentage[1]:
del quiz_precentage[1]
elif min(quiz_precentage) == quiz_precentage[2]:
del quiz_precentage[2]
elif min(quiz_precentage) == quiz_precentage[3]:
del quiz_precentage[3]
elif min(quiz_precentage) == quiz_precentage[4]:
del quiz_precentage[4]
elif min(quiz_precentage) == quiz_precentage[5]:
del quiz_precentage[5]
return quiz_precentage

how do you guys make your funky code thing show up like you do?

Just put your code in code-tags ;) (without the space at the first "code")

Instead of your many if's, you could write

minimum = min(quiz_percentage)
quiz_percentage.remove(minimum)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.