Feb. 17, 2024, 12:44 a.m. | Paulo GP

DEV Community dev.to

Python has a built-in random library. In this post, we'll explore some of the most commonly used functions in the random library, including generating random numbers, making random choices, and shuffling sequences.





Generating Random Numbers


The random library provides several functions to generate random numbers, including random, uniform, randint, and randrange. Here's an example of using these functions to generate random numbers representing the mass and radius of a hypothetical planet:



import random

# Generate a random floating-point number between …

beginners example explore functions generate library making numbers programming python random uniform

Data Architect

@ University of Texas at Austin | Austin, TX

Data ETL Engineer

@ University of Texas at Austin | Austin, TX

Lead GNSS Data Scientist

@ Lurra Systems | Melbourne

Senior Machine Learning Engineer (MLOps)

@ Promaton | Remote, Europe

Senior Data Engineer

@ Quantexa | Sydney, New South Wales, Australia

Staff Analytics Engineer

@ Warner Bros. Discovery | NY New York 230 Park Avenue South