Python Exercise Example54
# Python2.x Python Exercise Instance 54
[ Python 100 Examples](#)
**Question:** Extract the 4th to 7th bits from the right end of an integer a.
**Program Analysis:** You can consider it this way:
(1) First shift a right by 4 bits.
(2) Set a number where the lower 4 bits are all 1, and the rest are all 0. You can use ~(~0<>4 c = ~(~0<<4)d = b&c print('%ot%o' %(a,d))
The output result of the above instance is
YouTip