Class - 12 CBSE Computer Science Important Output Questions 2025
Write the output of the following Python code:
for i in range(2,7,2):
print(i*'$')
Python Funda
12 Likes
Answer
Output
$$
$$$$
$$$$$$
Explanation
range(2,7,2)
returns [2, 4, 6] as it defines a range of 2 to 6 with a step of 2. The loop iterates as below:
- For
i = 2
, it prints$$
. - For
i = 4
, it prints$$$$
. - For
i = 6
, it prints$$$$$$
.
Answered By
4 Likes