You can download this code by clicking the button below.
This code is now available for download.
This function generates a random number within a specified range and step.
Technology Stack : random
Code Type : Function
Code Difficulty : Intermediate
import random
def generate_random_number(min_value, max_value, step=1):
"""
Generate a random number within the specified range with a specified step.
:param min_value: The minimum value of the range (inclusive).
:param max_value: The maximum value of the range (inclusive).
:param step: The step size for the random number generation.
:return: A random number within the specified range and step.
"""
return random.randrange(min_value, max_value + 1, step)