Assign sum_extra with the total extra credit received given list test_grades. Full credit is 100, so anything over 100 is extra credit. For the given program, sum_extra is 8 because 1 + 0 + 7 + 0 is 8. Sample output for the given program with input: '101 83 107

Respuesta :

Answer:

The solution code is written in Python:

  1. scores = input("Enter marks: ")
  2. scores_list =  scores.split(" ")
  3. sum_extra = 0
  4. for x in scores_list:
  5.    if int(x) > 100:
  6.        sum_extra = sum_extra + int(x) - 100
  7. print(sum_extra)

Explanation:

Firstly, use input() method to prompt user to input the marks in a single string with each number separated by a space (e.g. 101 83 107) (Line 1).

Next, use split() method to separate the number into individual elements of the scores_list using the single space " " as a separator(Line 2).

Next, traverse through each number in the list and check if any number is bigger than 100. If so, deduct the number by 100 and add it to sum_extra (Line 7)

At last, output the sum_extra (Line 9)