Test Index
Functions in Python
© examsnet.com
Question : 16 of 23
Marks:
+1,
-0
Which of the following output will never be obtained when the given code is executed ?
import randomShuffle = random.randrange(10)+1Draw = 10*random.randrange(5)print ("Shuffle", Shuffle, end="#")print ("Draw", Draw)[CBSE 2024 Compartment]
Solution:
Concept:
random.randrange(n) returns a random integer from 0 to n-1.Explanation:random.randrange(10) gives 0 to 9, so Shuffle = 0+1 to 9+1 = 1 to 10.random.randrange(5) gives 0 to 4, so Draw = 10 × (0 to 4) = 0, 10, 20, 30 or 40.Option A (1, 0), Option B (10, 10) and Option C (10, 0) are all possible.Option D needs Shuffle = 11 and Draw = 50; neither value can ever occur.Answer:Option D (Shuffle 11 # Draw 50)© examsnet.com
Go to Question: