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
37
14
145
18.3K
Sergei Kotov
Sergei Kotov@kotov_dev·
@PythonPr Answer: A. 0 › range(1) generates only one value: 0 › Starts at 0 by default, stops before 1 › Loop runs once with i=0, prints 0 For beginners: range(n) gives you 0 to n-1, not 1 to n!
English
0
0
0
435
Big Smoke
Big Smoke@O_Danielz·
@PythonPr Answer is A, range(1) generates a sequence starting from zero excluding 1
English
0
0
0
637
Prem Prakash
Prem Prakash@4EverPrem·
@PythonPr 1. range functions can take 3 arguments, start, stop & step value. When only one argument is given, then it's the stop value and 0 becomes the start by default. Therefore, it will print 0 excluding 1.
English
0
0
0
358
Vern
Vern@FCACF17·
@PythonPr Mine said ‘syntax error’ under the word ‘range’. Is everybody using the Python version downloaded from their website?
English
0
0
0
84
Manish Khyalia
Manish Khyalia@Manish_Kumar60·
@PythonPr Answer:-A(0) If there is no starting value in range function then it start from 0 by default. The range function include the starting value but it exclude the ending value Ex:- range(1, 5) so it start from 1 and end at 4.
English
0
0
0
94
Ricky
Ricky@Ritesh___33·
@PythonPr A... because automatically range becomes (0,1) and doesn't include 1
English
0
0
0
3
Saptarshi🧋✌︎︎
Saptarshi🧋✌︎︎@Saptarshi177·
@PythonPr Correct Answer: A (0) In Python for i in range(1): print(i) range(1) generates a sequence starting from 0 up to (but not including) 1 → that means it produces [0]. So, the loop runs once, and i = 0.
English
0
0
0
7
Ravan(King of Lanka)
Ravan(King of Lanka)@anujxterminal·
@PythonPr Ans -0 Range 0 to 1 I went to iterate from 0 and print it after it went 1 but range includes so 1 is not going to print .
English
0
0
0
3
Paylaş