Computer Science

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

Python Data Handling

7 Likes

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.

Answered By

6 Likes


Related Questions