CBSE Python Random Module: 15 Must-Practice Output Questions
If you have solved previous CBSE Computer Science (083) papers, you already know that the random module question almost always appears in Section A. Many students think it’s an easy 2-mark question — but this is exactly where mistakes happen.
One small confusion about the range of randint() or randrange() can change the output completely and cost you full marks.
Whether your goal is scoring 100/100 or simply gaining confidence in Python output questions, these practice questions are designed to expose all the tricky patterns that examiners use again and again.
Why Should You Focus on the Random Module?
After analyzing many years of board papers, I’ve noticed that examiners are not testing memorization — they are testing your logic and attention to detail.
These questions mainly check whether you can:
- Carefully trace loops step-by-step
- Understand how random numbers select elements from lists or strings
- Identify which outputs are possible and which are not
- Students who rush usually lose marks here.
How to get the most out of this guide:
-
Instead of guessing answers, follow this simple method:
1. Determine the Range First
Always write down the minimum and maximum possible values that the random variable can generate.2. Do a Quick Dry Run
Trace the program manually for at least one or two cases. This helps you understand the pattern.3. Use Elimination Smartly
Check each option carefully. If even one value in an option falls outside your calculated range, you can eliminate it immediately.
Stuck on a Question?
No problem, Check the detailed explanation provided with each question to understand the logic step-by-step.
Remember — The more you practice, the stronger you become.
| 1. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random Cards=['Heart','Spade','Club','Diamond'] for i in range(2): print(Cards[random.randint(1,i+2)],end='#') |
|
| a) Spade#Diamond# | c) Diamond#Club# |
| b) Spade#Heart# | d) Heart#Spade# |
| Sol. Click here to check your answer | |
| 2. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random M=[5,10,15,20,25,30] for i in range(1,3): first=random.randint(2,5)-1 sec=random.randint(3,6)-2 third=random.randint(1,4) print(M[first],M[sec], M[third], sep='#') |
|
| a) 10#25#15
20#25#25 |
c) 5#25#20
25#20#15 |
| b) 30#20#20
20#25#25 |
d) 10#15#25
15#20#10 |
| Sol. Click here to check your answer | |
| 3. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random Game=[10,16] Turn=random.randint(0,1)+5 for i in range(2): P=random.randint(0,1) print(Game[P]+Turn,end="#") |
|
| a) 15#21# | c) 22#16# |
| b) 16#21# | d) 21#22# |
| Sol. Click here to check your answer | |
| 4. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random High=3 Guess=random.randint(0,High)+50 for i in range(Guess,56): print(i,end="#") |
|
| a) 50#51#52#53#54#55# | c) 53#54# |
| b) 51#52#53#54#55# | d) 52#53#54# |
| Sol. Click here to check the solution | |
| 5. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random Low=15 Point=5 for i in range(1,5): Number=Low+random.randint(0,Point-1) print(Number,end=":") Point-=1 |
|
| a) 19:16:15:18: | c) 15:18:17:16: |
| b) 19:16:14:18: | d) 19:16:15:16: |
| Sol. Click here to check your answer | |
| 6. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random Limit=4 Points=100+random.randint(0,Limit-1) for i in range(Points,99,-1): print(i,end="#") |
|
| a) 103#102#101#100# | c) 100#101#102#103# |
| b) 100#101#102#103#104# | d) 102#101#100# |
| Sol. Click here to check your answer | |
| 7. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random CITY= ["DEL","CHN","KOL","BOM","BNG"] for i in range(3): Fly=random.randint(0,1) print(CITY[Fly],end=":") |
|
| a) CHN:CHN:CHN | c) DEL:CHN:KOL |
| b) CHN:KOL:CHN | d) KOL:BOM:BNG |
| Sol. Click here to check your answer | |
| 8. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random Name="STUDYTRIGGER" Num=random.randint(0,3) N=9 while Name[N]!='R': print(Name[N]+Name[Num]+"#",end=' ') Num+=1 N-=1 |
|
| a) GD# GY# IT# | c) TU#GG#ER |
| b) ST#DY#ER# | d) UD#TR#GE# |
| 9. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
Base = 20
Step = 4
for i in range(1, 5):
Num = Base + random.randint(0, Step)
print(Num, end=':')
Step -= 1
|
|
| a) 24:23:22:21: | c) 20:21:22:23: |
| b) 21:22:23:24: | d) 24:25:23:22: |
| 10. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
S = "PYTHON"
i = random.randint(1, 3)
while S[i] != 'N':
print(S[i] + S[0] + "$", end=' ')
i += 1
|
|
| a) YP$ TP$ HP$ | c) TP$ HP$ OP$ |
| b) YP$ TP$ OP$ | d) HP$ OP$ NP$ |
| 11. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
Color = ['Red', 'Blue', 'Green', 'Yellow']
for i in range(2):
print(Color[random.randint(0, i+1)], end='@')
|
|
| a) Red@Green@ | c) Red@Blue@ |
| b) Blue@Yellow@ | d) Yellow@Red@ |
| Sol. Click here to check the answer | |
| 12. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
Word = ["Sun", "Moon", "Star", "Sky"]
for i in range(2):
A = random.randint(0, 3)
print(Word[A], end='#')
|
|
| a) Sun#Moon# | c) Moon#Moon# |
| b) Star#Sky# | d) Sun#Star# |
| Sol. Click here to check the answer | |
| 13. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
Num = random.randint(1, 5)
if Num % 2 == 0:
print(Num * 2)
else:
print(Num + 3)
|
|
| a) 2 | c) 7 |
| b) 6 | d) 10 |
| Sol. Click here to check your answer | |
| 14. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random S = "PYTHON" i = random.randint(0, 3) print(S[i:i+3]) |
|
| a) PYT | c) THO |
| b) YTH | d) HON |
| Sol. Click here to check your answer | |
| 15. Find the possible output from the given options is expected to be displayed when the following code is executed? | |
import random
PICK = random.randint(1, 3)
CITY = ["DELHI", "MUMBAI", "CHENNAI", "KOLKATA"]
for I in CITY:
for J in range(0, PICK):
print(I, end=" ")
print()
|
|
![]() |
|
| Sol. Click here to check your answer | |
Exam Special Recommendation: If you are studying in 12th class and preparing for your board exam, then go for the “Computer Science with Python Sample Paper Book“. It contains 3 previous years’ papers and 7 practice papers solved strictly as per the CBSE pattern. Click here to purchase your copy!
