Q. 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 =

 

Option (a) & (c) are the possible outcomes of the above code.

 

Max value: - nearly equal to 10, but not 10.

Min value:- 0.0

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post