Reassigning versus mutating a parameter

Consider the Python program below, which adds a bonus entry to a list of quiz marks. What number does the final line print? Give your answer as a whole number.


Python
def update(scores, bonus):
    bonus = bonus * 2
    scores.append(bonus)

marks = [70, 85]
extra = 5
update(marks, extra)
print(sum(marks) + extra)

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Parameters and Arguments Questions: