How to import random in python?
Random module- Function in this module depends upon the pseudo random number generator function random.
random()- Generates a random float number 0.0 to 1.0.
syntax:-
import random random.random()
randint()- Returns a random integer between the specified integers.
syntax:-
import random random.randint(1,100)
randrange()- Returns a randomly selected element from the range.
e.g.,
import random random.randrange(1, 10, 2)
choice()- Returns a randomly selected element from non-empty sequence.
e.g.,
import random random.choice("pythonpoint")
This is how we import random in python.
Subscribe
Login
Please login to comment
0 Discussion