CBSE 2026 · Central · Set 4 · Q25 · 2 marks
What possible output(s) from the given options will NOT be displayed when the following code is executed ? Also, mention, for how many iterations the for loop in the given code will run?import random
a = [1,2,3,4,5,6]
for i in range(4):
j = random.randrange(i,5)
print(a[j],end='-')
print()
Options :(A)$\displaystyle 3$-$\displaystyle 4$-$\displaystyle 5$-$\displaystyle 4$-(B)$\displaystyle 2$-$\displaystyle 2$-$\displaystyle 4$-$\displaystyle 5$-(C)$\displaystyle 4$-$\displaystyle 3$-$\displaystyle 3$-$\displaystyle 5$-(D)$\displaystyle 5$-$\displaystyle 1$-$\displaystyle 2$-$\displaystyle 4$-
What possible output(s) from the given options will NOT be displayed when the following code is executed ? Also, mention, for how many iterations the for loop in the given code will run?
import random
a = [1,2,3,4,5,6]
for i in range(4):
j = random.randrange(i,5)
print(a[j],end='-')
print()Options :
(A)
$\displaystyle 3$-$\displaystyle 4$-$\displaystyle 5$-$\displaystyle 4$-
(B)
$\displaystyle 2$-$\displaystyle 2$-$\displaystyle 4$-$\displaystyle 5$-
(C)
$\displaystyle 4$-$\displaystyle 3$-$\displaystyle 3$-$\displaystyle 5$-
(D)
$\displaystyle 5$-$\displaystyle 1$-$\displaystyle 2$-$\displaystyle 4$-
Marking-scheme solution
(D)
$\displaystyle 5$-$\displaystyle 1$-$\displaystyle 2$-$\displaystyle 4$-
The for loop will run for $\displaystyle 4$ iterations.
Revision of PythonOperators and ExpressionsAnalysevery_short_answer
More from Revision of Python
- State True or False: In Python, data type of 74 is same as the data type of 74.0.2026
- What will be the output of the following code snippet? t = tuple('tuple') t2 = t[2], t += t2 print(t)2026
- Assuming that D1 is a dictionary in Python, (i) Write a Python expression to check if the key, 'RNo' is…2026
- What will be the output of the following statement? print("PythonProgram"[-1:2:-2])2026
- Which of the following statements is true about dictionaries in Python?2026
- What is the output of the following code snippet? s='War and Peace by Leo Tolstoy' print(s.partition("by"))2026
- Write the output of the following code: def Exam2026(given): new=[] for ch in given[1:-1]: if ch.isupper():…2026
- Write a Python statement to perform the following tasks: (USE BUILT IN FUNCTIONS / METHODS ONLY) (i) To…2026
CBSE Class 12 Computer Science past-paper question from the 2026board exam, with the answer as CBSE’s own marking scheme gives it. Where our answers come from.