You can download this code by clicking the button below.
This code is now available for download.
Generate a random number within a specified range, used to simulate scenarios that require random numbers, such as random events in games.
Technology Stack : os, re, json, sys, time, math, random
Code Type : Function
Code Difficulty : Intermediate
import os
import re
import json
import sys
import time
import math
import random
def generate_random_number_range(min_value, max_value):
"""
生成一个指定范围内的随机数
"""
if min_value > max_value:
min_value, max_value = max_value, min_value
return random.randint(min_value, max_value)