logo CodeStepByStep logo

reference_mystery2

Language/Type: Python parameters reference semantics

When the main function below is called, the following code produces 4 lines of output. Write each line of output below as it would appear on the console.

def mystery(x, a):
    x = x * 2
    if x > 6:
        a[2] = 14
        a[1] = 9
    else:
        a[0] = 9
        a[3] = 14
    print(x, a)

def main():
    x = 1
    a = [0] * 4

    x = x * 2
    mystery(x, a)
    print(x, a)

    x = x * 2
    mystery(x, a)
    print(x, a)

main()
line 1
line 2
line 3
line 4

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.