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
27
12
114
12.1K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr Answer: B (3) For beginners: // is floor division (not regular division). It divides and drops the decimal: 10 / 3 = 3.333..., but 10 // 3 = 3. Remember: / = regular division, // = floor division. Double slash removes the fractional part!
English
0
0
0
302
Allen Floyd
Allen Floyd@alfloyd71·
@PythonPr The output is 3 because the // operator does floor division — it drops the decimal part. So 10 / 3 would be 3.333…, but 10 // 3 becomes 3.
English
0
0
0
127
Surtur
Surtur@Surtur·
@PythonPr Learn and love floor division!
English
0
0
0
343
James Edison
James Edison@JamesEdisonHQ·
@PythonPr Answer: B) 3. // is floor division — it returns the largest integer ≤ the exact quotient. 10/3 = 3.333…, floor → 3. (Edge case: it floors toward −∞, so -10 // 3 is -4, not -3.)
English
0
0
0
11
Joe
Joe@Joe46791334·
@PythonPr B integer division truncates fractions. // is divide with predjudice. ;)
English
0
0
0
54
Paylaş