1.

Which of the following expressions can be used to multiply a given number ‘a’ by 4?(a) a4This question was addressed to me in final exam.I need to ask this question from Bitwise in section Precedence and Associativity, Bitwise & Boolean of Python

Answer»

The CORRECT OPTION is (a) a<<2

Explanation: Let us consider an example wherein a=2. The binary FORM of 2 is 0010. When we left shift this value by 2, we get 1000, the value of which is 8. Hence if we WANT to multiply a GIVEN number ‘a’ by 4, we can use the expression: a<<2.



Discussion

No Comment Found

Related InterviewSolutions