One shared list, then two

A data-processing script uses the same Python list for both arguments in the call below. Determine the final values of data[0], data[1], and result. Enter each as a unitless integer, to zero decimal places.


Python
def revise(a, b):
    a[0] = a[0] + b[1]
    a = [20, 30]
    b[1] = a[0] - b[0]
    return a[1] + b[1]

data = [5, 7]
result = revise(data, data)


Two parameter names and the caller name point to the same initial list.


Your answers

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 Parameter Passing Questions: