Python Forum
How do i make a module that'll get me an average?! thx
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i make a module that'll get me an average?! thx
#1
#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()
Reply
#2
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
Reply
#3
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cannot make 'pandas' module to work... ellie145 2 4,136 Jan-05-2021, 09:38 PM
Last Post: ellie145

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020