Python Forum

Full Version: How do i make a module that'll get me an average?! thx
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
#This is the code i am trying to write
#its you're beginner "average test score" programming exercise
#how do i make a module that'll get the average , return the average and print the average?
#please help, thx
def main():

    endProgram, totalScores, counter, scores, averageScore, number = declaredVariables()

    while endProgram == "no":
        endProgram, totalScores, counter, scores, averageScore, number = declaredVariables()

        number = getNumber()
        totalScores = getScores(counter, scores, number, totalScores)


def declaredVariables():
    endProgram = "no"
    totalScores = 0.0
    counter = 0
    scores = 0.0
    averageScores = 0.0
    number = 0
    return endProgram, totalScores, counter, scores, averageScores, number

def getNumber():
    number = input("How many students took the test: ")
    return number

def getScores(counter, scores, number, toalScores):   
    for counter in range(0, 100):
        Scores = input("Enter score for the students: ")
        totalScores = totalScores + scores 

    return totalScores
        
main()
Hello everyone!

I basically need to make a module to get , return and print an average. I'm stuck because i don't know how pull off that string! it's a basic programming exercise i'm practicing. can anyone send me an example? thx and sorry for, one of many noob questions Wall
What do you mean you "don't know how to pull off that string"? We'd love to help, but in this thread it seems like you've posted your homework without actually asking a question.