+1 vote
in Python by
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

0 votes
asked Feb 11, 2021 in Python by SakshiSharma
+1 vote
asked Feb 14, 2021 in Python by SakshiSharma
...