Friday, September 22, 2023
HomeSoftware EngineeringFind out how to Get 10 Random Numbers in Python

Find out how to Get 10 Random Numbers in Python


The random module means that you can generate decisions.

import random
print(random.decisions([i for i in range(1000)], ok=10))

This would possibly give us again one thing like:

[635, 450, 26, 829, 786, 563, 294, 586, 893, 953]

Explaining random.alternative and random.decisions

random.alternative takes a sequence as a parameter and return a single random merchandise from it.

Whereas random.decisions takes a sequence as a parameter and returns a number of random objects from it. You may specify what number of random objects to return by populating the ok= parameter, as above.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments