GIAC Python Coder (GPYC) — Question 2
What is the output of the following line of code typed into a Python interactive session?
>>> print (int(`1111`,2))
Answer options
- A. 1111
- B. 16
- C. ג€1111ג€
- D. 15
Correct answer: D
Explanation
The code converts the binary string '1111' to its decimal equivalent, which is 15. Option A is incorrect because it does not convert the binary to decimal. Option B is incorrect as it suggests the decimal value of 16, which is not the case. Option C is also incorrect as it shows an incorrect representation of the string.