Slide to the Left


#1



WHAT IS MY PROBLEM!?

shift_right = 0b1100
shift_left = 0b1

# Your code here!
0b1100 >> 2 == 0b0011
0b1 << 2 == 0b11
print bin(shift_right >> 2)
print bin(shift_left << 2)


#2

No idea.

Your code on the other hand I can help with.

If you want to see what a number looks like in binary do the following,

def binary(number):
    return "0b{b}".format(number)

print(binary(6))

Now on to bit shifting,

An example:

print(bin(0b1100 >> 2))
# above your first part and below an example of bit shifting
print(bin(0b1 << 1))

print(bin(0b10 << 1))

print(bin(0b100 << 1))

print(bin(0b1 >> 1))

print(bin(0b10 >> 1))

print(bin(0b100 >> 1))

Run them examples and you should get a good idea of what is going on.

If you still need some help ask away.