Random Number Generator within Range

  • Share this:

Code introduction


This function generates a random number within a specified range.


Technology Stack : random.randint()

Code Type : Function

Code Difficulty : Intermediate


                
                    
import math
import random

def generate_random_number_range(min_value, max_value):
    """
    Generate a random number within a specified range.

    :param min_value: The minimum value of the range (inclusive).
    :param max_value: The maximum value of the range (inclusive).
    :return: A random number between min_value and max_value.
    """
    return random.randint(min_value, max_value)