Question: python ** Coding question. You can refer to the codes from materials. And try/practice in the python playground or env if you set it up
python **
Coding question. You can refer to the codes from materials. And try/practice in the python playground or env if you set it up before answering these questions.
(Numeric type) Bitwise operation
Question 2-1: Please use left shift operation << to show how to calculate m multiplies 2 to the power of n.
Question 2-2: Please use right shift operation >> to show how to calculate m over 32. (Assume m is positive integer and divisible by 32)
Question 2-3: Find number of bits needed to be flipped to convert 12345678 to 202110
Hints:
1) xor operation ^ - if two bits are different it returns 1; otherwise, return 0.
2) try bin(3).count("1"). This gets the number of 1 in bit in number 3.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
