in Python by
Q:
How can you get a random number in python?

► Click here to show 1 Answer

0 votes
by

To generate a random, we use a random module of python. Here are some examples To generate a floating-point number from 0-1

import random

n = random.random()

print(n)

To generate a integer between a certain range (say from a to b):

import random

n = random.randint(a,b)

print(n)

Great Learning offers extensive courses on Artificial Intelligence and Machine Learning. Upskilling in this domain can land you the job of your dreams.

Python
Learn More with Madanswer

Related questions

...