Turn it on


#1



a = 0b10111011
print bin(a|0b1)
"""please tell me what to do in this question"""


Replace this line with your code.


#2

a = 0b110 # 6
mask = 0b100 # 1
desired = a | mask # 0b111, or 7
print bin(desired)

"""
Oops, try again. The correct binary string was not printed!
"""


#3

| is bitwise or.

simply lets take two binary numbers..

x = 0b1000
y = 0b0100

Now if we do this..

x | y, each bits are Or-ed then result gets evaluated which is 0b1100.
rule is simple..
(The | works like this)..

Masking simply means if something is off mode ,make it on(1)
if its on mode make if off (0)

question asks to mask third bit from right side of a,
so you need a mask and make sure its third bit is 1 as third bit of a is 0.


#4

a is already defined in the exercise.

a = 0b10111011


#5

a = 0b10111011
b=0b1
print bin(a|b)

what wrong is there now.


#6

Sry i got my mistake....


#8

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