logo CodeStepByStep logo

while_mystery_1

Language/Type: Python loops

Given the following function, write the output of each of the following calls:

def mystery(x):
    y = 1
    z = 0
    while 2 * y <= x:
        y = y * 2
        z += 1
    print(y, z)
mystery(1)
mystery(6)
mystery(19)
mystery(39)
mystery(74)

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.