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
40
8
136
20.3K
Kamal Gurjar
Kamal Gurjar@KamalGurjar8·
@PythonPr Indentation matters in Python. print(x) is inside the loop, so it runs every iteration. Output will be: 0 1 3 None of the given options are correct.
English
1
0
8
2K
ANKIT 𓃱
ANKIT 𓃱@A9kitSingh·
@PythonPr Answer: A) 3 range(3) gives 0, 1, 2. x starts at 0 and accumulates: 0 + 0 + 1 + 2 = 3.
English
0
0
5
552
Jenny
Jenny@JennyTheDev·
@PythonPr A) 3 Step by step: i=0 → x = 0+0 = 0 i=1 → x = 0+1 = 1 i=2 → x = 1+2 = 3 range(3) = [0,1,2], sum = 3
English
0
0
4
926
Smart💡
Smart💡@capt_ivo·
@PythonPr So, I wanted to commend @KamalGurjar8 in his reply for spotting the wrong indentation, but he already blocked me because he feel threatened when I criticized his wrong answer in an earlier post 🤣. But now, he appears correct with his answer. Take note of your indentation
English
0
0
2
1.4K
Savage Scripts
Savage Scripts@savage_scripts·
@PythonPr For i in range(3) is 0,1,2 x = x + i is (0+0) + (0+1) + (0+2) x = 3 Answer is A
English
0
0
2
173
🍉
🍉@Xndroids·
@PythonPr For i in range(3) is 0,1,2 x = x + i is (O+0) + (O+1) + (0+2) & Answer is A
English
0
0
2
129
Abdulrahman
Abdulrahman@abdul_amyz·
@PythonPr The answer is A) 3 In range (3) to repeat the answer in the number in range, x = x+1 will be repeated 3 times, 0 + 1 =1 1 + 1 = 2 2 + 1 = 3 the answer: x=3
Abdulrahman tweet media
English
0
1
0
333
Chrome
Chrome@ChromeDash·
@PythonPr The correct answer is Indentation Error.
English
0
0
1
784
asteroid
asteroid@earth_asteroid·
@PythonPr Answer D, because the last line has an indentation error
English
0
0
1
697
PennyBrew
PennyBrew@ARM_TheFirst·
@PythonPr 0 At least that's the first of all the numbers from 0 to 3 that would be printed. This is because of the indentation. If "print" was on the same level as the for loop, the answer would be 3
English
0
0
1
740
badrsami
badrsami@badrsami25·
@PythonPr Error.. because the print is not part of the for loop nor outside the for loop. Indentation mistake
English
0
0
1
198
clovis
clovis@cloclodma·
@PythonPr This is an error Indentation problem
English
0
0
0
21
Python Tech
Python Tech@PythonTech43716·
@PythonPr Indentation error on this code . If no error then output will be 3
English
0
0
0
5
laso
laso@lasitolas·
@PythonPr A...summation starts from 0 to 3 as stated in the range. for i in range(3)
English
0
0
0
52
Paylaş