CBSE Class 11 Computer Science Question 147 of 173

Data Handling — Question 36

Back to all questions
36
Question

Question 23

Consider the code given below:

import random
r = random.random() * 10
print(r, end = ' ')
r = random. random() * 10
print(r, end = ' ')
r = random.random() * 10
print(r)

Which of the following are the possible outcomes of the above code? Also, what can be the maximum and minimum number generated by line 2 ?

(a) 0.5 1.6 9.8
(b) 10.0 1.0 0.0
(c) 0.0 5.6 8.7
(d) 0.0 7.9 10.0

Answer

The possible outcomes of the above code can be:

Option (a) — 0.5 1.6 9.8
Option (c) — 0.0 5.6 8.7

Maximum number can be 9.999999..... and minimum number can be 0.

Answer