Questions: Function Parameters and Argument Passing

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

In Python, consider: `def double(x): x = x * 2`. After running `n = 5; double(n)`, what is the value of n?

A10 — the function modified x, and x was bound to n
B5 — x is a local variable; reassigning x inside the function does not affect n
CNone — functions without return statements set caller variables to None
DAn error occurs because x is modified inside the function
Question 2 Multiple Choice

A function is defined as `def append_zero(lst): lst.append(0)`. After running `my_list = [1, 2]; append_zero(my_list)`, what is `my_list`?

A[1, 2] — the function worked on a copy of the list
B[1, 2, 0] — the parameter referred to the same list object in memory
C[0] — the function replaced the list's contents
DAn error — lists cannot be passed as arguments
Question 3 True / False

Modifying a parameter inside a function usually changes the original variable that was passed as the argument.

TTrue
FFalse
Question 4 True / False

The terms 'parameter' and 'argument' refer to different things: parameters are the named placeholders declared in a function's definition, while arguments are the actual values supplied when the function is called.

TTrue
FFalse
Question 5 Short Answer

Explain why calling `lst.append(42)` inside a function changes the caller's list, but assigning `lst = []` inside the same function does not.

Think about your answer, then reveal below.