Random Number Generator using Python#s random Module

  • Share this:

Code introduction


This function uses the random module to generate a random integer between min_value and max_value.


Technology Stack : Python, random

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
import random
import fire

# Define a custom function using the random module from the Python Standard Library
def generate_random_number(min_value, max_value):
    """
    Generate a random number between min_value and max_value.
    """
    return random.randint(min_value, max_value)

# Add the function to the Fire library for command-line usage
if __name__ == "__main__":
    fire.Fire(generate_random_number)                
              
Tags: