Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Average score
#5
I'm almost there but I'm missing something can you tell me what? The error I get from repl.it is Traceback (most recent call last):

 File "python", line 30, in <module>

 File "python", line 25, in main

 File "python", line 10, in while_loop
ValueError: could not convert string to float:



def scoretimes():
    print("How many grade scores would you like to enter?")
    scores = int(input())
    return scores

def while_loop(scores):
    times = 1
    scoretotal = 0
    while times <= scores:
      scoreinput = float(input("Enter score:"))
      scoretotal += scoreinput
      times += 1
    return scoretotal

def get_calculation(scores, scoretotal):
    calculation = scoretotal / scores
    return calculation

def display_result(calculation):
    print("The Average score is:" + str(calculation))
    

def main():
  scores = scoretimes()
  while_loop(scores)
  calculation = get_calculation(scoretotal, scores)
  display_result(calculation)


main()
Reply


Messages In This Thread
Average score - by MartinEvtimov - Mar-29-2017, 04:19 PM
RE: Average score - by nilamo - Mar-29-2017, 04:53 PM
RE: Average score - by Larz60+ - Mar-29-2017, 05:04 PM
RE: Average score - by zivoni - Mar-29-2017, 10:13 PM
RE: Average score - by MartinEvtimov - Apr-02-2017, 06:15 PM
RE: Average score - by ichabod801 - Apr-02-2017, 07:35 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to update score value? Mavoz 5 2,576 Nov-08-2022, 12:37 AM
Last Post: Mavoz

Forum Jump:

User Panel Messages

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