Python Forum
Find Average of User Input Defined number of Scores
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find Average of User Input Defined number of Scores
I am attempting to write a short practice script that finds the average of a user defined number of scores.

Here is the code I have:

total = int(input('How many scores are there? '))
total_sum = 0

for i in range(total):

    Scores = float(input('Enter a score : '))

total_sum += Scores

avg = Scores / total_sum

print ('The average of the scores is: ', avg)
My goal is for this to calculate the average but it doesn't seem to be doing that. What it's doing is calculating something else. No matter how I change it up it keeps giving me odd answers.

Can anyone tell me what I'm doing wrong?
scores = []
while True:
        score = int(input('Enter a score or -1 to quit: '))
    except ValueError:
        print(f"Please enter a number")
    if score == -1:
print(f"Mean of scores is {sum(scores)/len(scores)}")

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help to find the largest int number in a file directory SalzmannNicholas 1 88 Jan-13-2022, 05:22 PM
Last Post: ndc85430
  Matplotlib - close multple plots with user input Positron79 0 218 Dec-01-2021, 05:26 PM
Last Post: Positron79
  Exit function from nested function based on user input Turtle 5 758 Oct-10-2021, 12:55 AM
Last Post: Turtle
  Unable to access the user input value given to daterangepicker klllmmm 1 940 May-26-2021, 09:16 PM
Last Post: nilamo
  Problem restricting user input in my rock paper scissors game ashergreen 6 1,604 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  LinkedList by User Input SantiagoPB 5 1,854 Mar-03-2021, 09:54 PM
Last Post: deanhystad
  User input/picking from a list AnunnakiKungFu 2 1,015 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  Generate Random operator, take user input and validate the user mapypy 4 1,546 Feb-03-2021, 08:41 PM
Last Post: nilamo
  Regular expression: cannot find 1st number in a string Pavel_47 2 1,039 Jan-15-2021, 04:39 PM
Last Post: bowlofred
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 1,471 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes

Forum Jump:

User Panel Messages

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