Question 40

Select the correct output for the following Python code. for I in range (6, 1, -2) :

Select the correct output for the following Python code. for I in range (6, 1, -2) : print (end = '*$$')
  1. A*$$*$$
  2. B*$$ *$$ *$$
  3. C*$$*$$*$$
  4. D*$$ *$$
Show answerHide answer

Correct answer: (C) *$$*$$*$$

Explanation

range(6, 1, −2) gives 6, 4 and 2, so the loop runs 3 times. print(end='*$$') prints only '*$$' with no newline, giving *$$*$$*$$.

From DSSSB TGT Computer Science Practice Set 3

This is question 40 of DSSSB TGT Computer Science Practice Set 3. See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.