Write a function setbit
that takes three arguments: an integer int
, int
, bool
). The integer True
(1
) or False
(0
). The bits of True
, the function must the bit of False
, the function must the bit of
Write a function getbit
that takes two arguments: an integer int
, int
, setbit
. The function must return a Boolean value (bool
) that indicates if the bit of
Write a function bitstring
that takes an integer int
, str
).
>>> store = setbit(0, 0, True)
>>> store
1
>>> getbit(store, 0)
True
>>> bitstring(store)
'00000001'
>>> store = setbit(store, 1, True)
>>> store
3
>>> getbit(store, 1)
True
>>> bitstring(store)
'00000011'
>>> store = setbit(store, 2, False)
>>> store
3
>>> getbit(store, 2)
False
>>> bitstring(store)
'00000011'
>>> store = setbit(store, 3, True)
>>> store
11
>>> getbit(store, 3)
True
>>> bitstring(store)
'00001011'
>>> store = setbit(store, 4, False)
>>> store
11
>>> getbit(store, 4)
False
>>> bitstring(store)
'00001011'
>>> store = setbit(store, 5, True)
>>> store
43
>>> getbit(store, 5)
True
>>> bitstring(store)
'00101011'
>>> store = setbit(store, 1, False)
>>> store
41
>>> getbit(store, 1)
False
>>> bitstring(store)
'00101001'