1.

To find the decimal value of 1111, that is 15, we can use the function:(a) int(1111,10)(b) int(‘1111’,10)(c) int(1111,2)(d) int(‘1111’,2)I have been asked this question in an interview.Origin of the question is Bitwise in chapter Precedence and Associativity, Bitwise & Boolean of Python

Answer»

The CORRECT choice is (d) int(‘1111’,2)

The best explanation: The expression int(‘1111’,2) GIVES the result 15. The expression int(‘1111’, 10) will give the result 1111.



Discussion

No Comment Found

Related InterviewSolutions