Post

Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
28
18
174
22.8K
Jay
Jay@learnaiwthme·
@PythonPr The answer is B) 3. int('11', 2) means “interpret the string '11' as a base-2 (binary) number.” In binary: 11₂ = 1·2¹ + 1·2⁰ = 2 + 1 = 3 So print(a) outputs 3.
English
0
0
14
1.5K
Sixtus Agbakwuru
Sixtus Agbakwuru@SixtusAgbakwuru·
@PythonPr The correct answer is B (3 ) ✅ The int() function's second argument is the base. int('11', 2) means "convert the binary string '11' to a decimal integer." In binary, the rightmost 1 equals 1, and the leftmost 1 equals 2. 1 + 2 = 3.
English
0
0
9
1.9K
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: B) 3 The code uses the int() function with two arguments. The first argument, '11', is the string to be converted to an integer. The second argument, 2, specifies the base of the number system for the input string, which is binary (base-2). In binary, the number '11'
English
2
0
7
862
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Output: B) 3 int('11', 2) treats '11' as a binary number. Binary 11 = 3 in decimal.
English
0
0
2
1.2K
Blezolad
Blezolad@Blezolad_2·
@PythonPr The correct answer is 3, since the question is in talking about binary
English
0
0
1
149
Jenny
Jenny@JennyTheDev·
@PythonPr B) 3 int('11', 2) converts '11' from binary to decimal. Binary 11 = 2 + 1 = 3 The second parameter is the base, not a multiplier.
English
1
0
1
739
Pat Garner
Pat Garner@patgarner·
@PythonPr b) 3 base 2 = binary 11 binary = 3 decimal
English
0
0
1
919
Precious Rufus
Precious Rufus@ACHI_D_GREAT1·
@PythonPr JavaScript A 2 Numbers are not strings Correct if I’m wrong
English
0
0
0
56
Hamza Abdullahi
Hamza Abdullahi@home_boee1·
@PythonPr Imagine the binary '11' as a pair of mischievous fireflies in the digital night sky—one glowing for the 2's place (that's 2), the other for the 1's place (that's 1). lliance: 2 + 1 = 3. Not 11 in our everyday world, but a clever twist that ignites the code! So, the output?
English
1
0
0
5
Paylaş