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
34
9
188
15.8K
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr Answer: C. 0 0 Solution: Just need to be clear on `range` usage with a single argument. range(a) is equivalent to range(0, a) ie, starting from 0, stopping at a (a won't be in the range). So, range(1) is range(0, 1) starting from 0, stopping before 1. So just 0 +
English
1
0
3
242
Coding Computing Coach
Coding Computing Coach@CodingComputing·
@PythonPr The code in the question can be simplified to for i in [0]: for j in [0]: print(i, j) Since the loops run only once, it's very easy. The print runs only once, with i as 0 and j as 0 So, effectively print(0, 0) That outputs the values with a space in between, 0 0 Answer!
English
0
0
1
42
Paylaş