Hi there, i'm struggling with a program, i feel like i am really close to getting it but i cannot find a way to use the target variables inside of a loop: I'm trying to get the program to ask the user, how many grades are you going to enter. Then i want to work out the average which is fine. But then i want the loop to print out from each grade entered the letter grade as per my if statement. All it does is print the last grade out a certain number of times. Is this even possible or am i overthinking it?
Some code is: def main(): gradesEntered = 0 score = 0 numberOfGrades = 0 #get the number of grades being checked numberOfGrades = int(raw_input("Please enter the number of grades:" )) #Begin a 'for' loop to enter each score while numberOfGrades != gradesEntered: grade = int(raw_input("Please enter the grade:" )) gradesEntered += 1 score =+ grade grade = [numberOfGrades] for i in range (numberOfGrades): grade.append(i) print determine_grade(grade,i) #get the grade letter for scores print "the total number of grades entered are:", score print "The average of the scores is:", calc_average print "The number of grades entered is:", gradesEntered def determine_grade(grade,i): if grade >= 90 and grade <= 100: result = 'Your grade is A' elif grade >=80 and grade <= 89: result = 'Your grade is B' elif grade >= 70 and grade <= 79: result = 'Your grade is C' elif grade >=60 and grade <= 69: result = 'Your grade is D' elif grade < 60: result = 'Your grade is F' else: print 'Error: Invalid grade.' return result main() Thank you in advance!
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor