Question 10

What minimum and maximum values will be generated for the following Python statement?

What minimum and maximum values will be generated for the following Python statement? print (random.randrange (100)+1)
  1. A1 and 100
  2. B0 and 100
  3. C1 and 99
  4. D0 and 99
Show answerHide answer

Correct answer: (A) 1 and 100

Explanation

random.randrange(100) returns an integer from 0 to 99 (the stop value is excluded). Adding 1 gives a range of 1 to 100.

From DSSSB TGT Computer Science Practice Set 1

This is question 10 of DSSSB TGT Computer Science Practice Set 1. 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.