What will be the output of the following Python code snippet if x=1? x<<2

Questions & AnswersCategory: Programming LanguageWhat will be the output of the following Python code snippet if x=1? x<<2
1 Answers
Geek Boy Staff answered 2 years ago

a. 4
Explanation: The binary form of 1 is 0001. The expression x<<2 implies we are performing bitwise left shift on x. This shift yields the value: 0100, which is the binary form of the number 4.