CBSE Class 12 Computer Science Question 59 of 120

Review of Python Basics — Question 11

Back to all questions
11
Question

Question 9(iii)

Write the output of the following:

for j in range(10, 6, -2): 
    print(j*2)
Answer
Output
20
16
Explanation

The range(10, 6, -2) function creates a range starting from 10 and decrementing by 2 until it reaches 6 (but does not include 6), resulting in the sequence [10, 8]. The for j in range(10, 6, -2): statement sets up a for loop that iterates over each element in the generated sequence [10, 8]. During each iteration of the loop, the print(j*2) statement prints the value of j multiplied by 2.