Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Needs to be in python Your first task here is to input score values to a list ca

ID: 3857208 • Letter: N

Question

Needs to be in python

Your first task here is to input score values to a list called scores and you will do this with a while loop. That is, prompt user to enter value for scores (integers) and keep on doing this until user enters the value of -99. Each time you enter a value you will add the score entered to list scores. The terminating value of -99 is not added to the list Hence the list scores should be initialized as an empty list first using the statement: scores = [] Once you finish enter the values for the list, define and called a find called print_scores() that will accept the list and then print each value in the list in one line separate by space. You should use a for-loop to print the values of the list.

def print_scores(copy_scores):
for one_score in copy_scores:
print(one_score, end = ' ')
  
scores = [75, 84, 66, 99, 51, 65]

print_scores(scores)
print()

Explanation / Answer

Please find the required solution:

import sys

def print_scores(copy_scores):
for one_score in copy_scores:
sys.stdout.write(str(one_score))
sys.stdout.write(' ')
print ''
  
scores = []
a = int(input("Enter a number: "))
while (a != -99):
scores.append(a);
a = int(input("Enter a number: "))

print_scores(scores)

Sample Input and output:

Enter a number: 75                                                                                                                                                        

Enter a number: 84                                                                                                                                                        

Enter a number: 66                                                                                                                                                        

Enter a number: 99                                                                                                                                                        

Enter a number: 51                                                                                                                                                        

Enter a number: 65                                                                                                                                                        

Enter a number: -99                                                                                                                                                       

75 84 66 99 51 65

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote