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

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.

Related questions

+1 vote
asked Feb 15 in Python by SakshiSharma
0 votes
asked Feb 10 in Python by SakshiSharma
...