In Python, you can generate random numbers using the random module. To generate a random integer within a specified range, use random.randint(a, b), where a is the lower bound and b is the upper bound (inclusive). Here’s an example:
import random
random_number = random.randint(1, 10) # Generates a random number between 1 and 10
print(random_number)
For generating a random floating-point number between 0 and 1, use random.random(). Additionally, for more control over random number generation, you can use random.uniform(a, b) for float ranges or random.choice() for random selection from a list.