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
36
11
144
13.1K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Answer: 10 14 Why: Start num = 10 → printed num += 4 → 14 → printed num += 4 → 18 → break runs before printing So 18 is never printed.
English
0
0
11
737
Tripti Choudhary.
Tripti Choudhary.@Tripti0101·
@PythonPr 10 14 When 18 comes it will break the condition and will come out from the while loop .
English
0
0
3
473
Earnest Codes
Earnest Codes@Earnesto037·
@PythonPr Answer: 10 14 Explanation; The code is a Python while loop that iterates until the condition num < 20 is met or a break statement is encountered [1.1]. num is initialized to 10. The while loop starts. Since 10 < 20 is true, it prints the current value of num, which is 10.
English
1
0
3
415
Omo Yewa
Omo Yewa@AceKelm·
@PythonPr A. 10 14. REASON: when num = 10 it prints 10. When num = num + 4 = 10 + 4 = 14. When num = num + 4 = 14 + 4 = 18. At this point, the if block of the code comes into play and the code breaks because at this point, num == 18. Therefore the only output to be printed is 10 14.
English
0
0
2
407
PlayStation Guy
PlayStation Guy@LinuxGamer23·
@PythonPr 10 14, while the number does reach 18. It never prints because it hits the line where it breaks
English
0
0
0
2
Kanye stanley
Kanye stanley@Kanyestanley7·
@PythonPr 10,14 since num != 18. It will break before printing 18.
English
0
0
0
125
Blaze H.
Blaze H.@BlazeHeru·
@PythonPr 10 14. num is less than 20 write num and num += 4
English
0
0
0
58
Paylaş