logo CodeStepByStep logo

while_mystery_2

Language/Type: Python loops

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

def mystery(x):
    y = 0
    while x % 2 == 0:
        y += 1
        x = x // 2
    print(x, y)
mystery(19)
mystery(42)
mystery(48)
mystery(40)
mystery(64)

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.