11. The man behind bit mask


#1



https://www.codecademy.com/es/courses/python-intermediate-en-oen3g/2/1?curriculum_id=53a32847fed2a88075000001#


¡Uy! Probá otra vez. Tu función falla en controla_bit4(0b1). Devuelve "on" en vez de devolver "off".


Hi, I have trouble with my code I think that's works.
What's wrong here I can't understand!!!!

def control_bit4(number):
    mask = 0b1100
    desired = mask & number
    if desired > 0:
        return "on"
    else:
        return "off"
        
print control_bit4(0b10)


#2

You have to change name of the function to controla_bit4 (add a).

You were asked to:

Debe revisar si el cuarto bit, comenzando desde la derecha, está encendido.

But your code will check if the fourth or the third bit is on. You have to change the mask to 1000.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.