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

Needs to be in python: Now we will try to enter score values to list scores usin

ID: 3857310 • Letter: N

Question

Needs to be in python:

Now we will try to enter score values to list scores using a different method. It will be the same method used in example 8.3.2 You will enter all the scores in one line separated by a space and once done, press Enter. If you look at 8.3.2 you have this line (shown below) after calling the input() function. tokens = user_input.split() The split() function separate values into different values and placed it into tokens. You can use this same code in your program but note in next lines, it appends each value to a list called nums. In our example, you will add values to your scores list. Again, you will call the print_scores() function to print your list hence show that your input of scores works.

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

Explanation / Answer

#Updated code by using split function and also get all input together

def print_scores(copy_scores):
for one_score in copy_scores:
print(str(one_score))
print(' ')
print('')
  
scores = []
scores_string = input("Enter scores separted by space: ")
scores = map(int, scores_string.split(" "))
print_scores(scores)

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