Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Random Number Generation

The 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.

INSTRUCTIONS
  • Import random module
  • Generate a random number and store it in the variable random_number
  • Convert the random_number into int using the type conversion and store it in random_int

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...