Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left
03 D 06 H : 26 M : 14 S Apply NowThe random
module provides functions that generate pseudorandom numbers.
import random
random.random()
It returns a random float value between 0.0 and 1.0 (including 0.0 but not 1.0).
Each time you call random
, you get the next number in a long series. To see a sample, run this loop and observe the results:
for a in range(10):
number = random.random()
print(number)
This loop runs from 10 times and prints a random in every iteration.
random
modulerandom_number
random_number
into int
using the type conversion and store it in random_int
Taking you to the next exercise in seconds...
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Please login to comment
0 Comments
There are 52 new comments.