How to generate a random number in a specific range in Python?

To generate a random number in a specific range in Python, you can use the random module. Here's an example:

import random # Generate a random integer between a specific range (inclusive) random_number = random.randint(start_range, end_range) # Generate a random floating-point number between 0 and 1 random_float = random.random() # It's equivalent to random.uniform(0, 1) # Generate a random floating-point number within a specific range random_float_in_range = random.uniform(start_range, end_range)

Note: In the above code, start_range and end_range refer to the desired range of values for the random number.