Q. Consider the following code:
import math
import random
print (str(int (math.pow( random.randint (2, 4), 2))), end = ' ')
print (str(int (math.pow( random.randint (2, 4), 2))), end = ' ')
print (str(int (math.pow( random.randint (2,4), 2))))
What could be the possible outputs out of the given four choices?
(i) 234
(ii) 944
(iii) 16 16 16
(iv) 249
(v) 494
(vi) 444
Answer :-
The possible outputs could be (ii), (iii) (v) and (vi).
The reason being that randint() would generate an integer between range 2...4, which is then raised to power 2, so possible outcomes can be any one of these three: 4,9 or 16.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )