## School Assignment having trouble Teacher = asshat

For the discussion of Perl, Python, Ruby, and PHP and other interpreted languages.

### School Assignment having trouble Teacher = asshat

My goal = "Write a program that will allow a teacher to calculate the average test score for a certain number of students. The teacher can enter the number of students who took the test, and then the score for each student. Your program will then calculate the average score and print out the results. Your program must use the appropriate loop, modules, and run multiple times for different sets of test scores."

This is what I attempted to write so far
It says that number students is not defined on the line where getGrades() is called
It looks right to me =\ teacher just says to figure it out myself when I am stumped

Code: Select all
`#This program is used to find the students average#This code is written by Charles Barnett on October 7#This is the main functiondef main():    retry = 'y'    while retry == 'y' or retry == 'Y':       getStudents()#This calls number of students       getGrades(numberStudents)#This calls the total grades       getAverage(testGrades, numberStudents)#This determines the average       printInfo(studentsAverage)#This prints out the results       retry = input('Would you like to try another class? (N for No Y for Yes)')#This function gets the number of students in a classroomdef getStudents():   numberStudents = input('Please enter number of students in classroom ')   numberStudents = int(numberStudents)   return numberStudents#This function gets the total test scoredef getGrades(numberStudents):   for number in range(numberStudents):    grade = input('Please enter students score')    grade = float(grade)    testGrades = testGrades + grade    return testGrades#This function gets the average score of all the studentsdef getAverage(testGrades, numberStudents):   studentsAverage = testGrades / numberStudents   return studentsAverage#This function prints out the students average scoresdef printInfo(studentsAverage):   print 'Your total average is ', studentsAveragemain()`

--------------------------------------------------------------------------------------------------------------

Edit: woops sorry I didn't know how I posted twice, well anyways please post here
coldghost213
New User

Posts: 15
Joined: Wed Jun 25, 2008 9:04 pm
Blog: View Blog (0)

### Re: School Assignment having trouble Teacher = asshat

You aren't saving your return values!

tgoe
Contributor

Posts: 715
Joined: Sun Sep 28, 2008 2:33 pm
Location: q3dm7
Blog: View Blog (0)

### Who is online

Users browsing this forum: No registered users and 0 guests