Hello,
I need help writing a program that reads in 10 test scores. The test scores should be integers and should be stored in an array and they should print out the test scores in ascending order with the average. This is what I have so far:
# list() function return the elements passed as arguments as a list
# map() function applies the function pased as first argument to all elements passed after this argument
# strip() function removes the leading and trailing spaces
# split() function splits the string using space as delimeter
scores = list( map( int, input('Enter 10 test scores (seprated by space) : ').strip().split(' ') ) )
scores = list( map( int, input('Enter 10 test scores (separated by space) : ').strip().split(' ') ) )
scores.sort()
total = 0
print('Scores : ', end = '')
for x in scores:
print(x, end = ' ')
total += x
average = total / len(scores)
print('\nTotal Score :', total)
print('Average Score :', average)
Enter 10 test scores (separated by space) : 1 2 3 4 5 5 4 3 2 1
Scores : 1 1 2 2 3 3 4 4 5 5
Total Score : 30
Average Score : 3.0
Process finished with exit code 0