Give output for i in range(2) print(0) for i in range(4,6) print(i) Select one: O a. 2,4,6 O b. 0, 1,4,5 O c. 0, 1,4,5,6,7,8,9 O d. 0, 1, 2, 4, 5, 6 O e. 1,2,4,5,6
Answers
Hello Mate! Here is the answer for your question.
Correct Question:
Give the output for the following:
for i in range(2):
print(i)
for i in range(4,6):
print(i)
Select one:
a. 2,4,6
b. 0, 1,4,5
c. 0, 1,4,5,6,7,8,9
d. 0, 1, 2, 4, 5, 6
e. 1,2,4,5,6
The correct output for the given input is Option - B
Considering the first case:
for i in range(2):
print(i)
In the above input, the range given to us is 2. Therefore, on printing i, we get the output as
0
1
[Note that Python do not take the end number in the output.]
Considering the second case:
for i in range(4,6):
print(i)
As we observe the above input, the starting number in the output will be 4 (as given) and the ending number will be 5 (not 6 as end numbers given in input is not taken by Python and only the preceding number is taken into account).
Therefore, on printing i, the output will be:
4
5
Overall result:
Therefore, overall; on combining the first and second cases, we can say that the output is:
0
1
4
5
Therefore, Option - B is the correct answer.