DAV Centenary Public School, Haldwani
Class: XII, (Session: 2023-24), Sub: Computer Science
Topic: Using Python Libraries
Q1: What will be the possible output of following code fragment?
import random
print(18 + [Link]()*5)
Ans:
[Link]( ) means to use random( ) function of random module(library).
Whenever we use library function of other libraries then we have to use .(dot) operator
with name of module.
random( ): random( ) will generate random numbers greater than equal to 0 and less than
1
when it is multiplied with 5, the range becomes 0.0 to less than 5(<5)
When 18 is added to it, the range becomes 18 to <23