Generate Random Number

Theory:

A random number is a number chosen as if by chance from a range of possible values.

Python Code:

import random

def generate_random_number(start, end):
return random.randint(start, end)

# Taking input from the user for range
start = int(input("Enter the start of the range: "))
end = int(input("Enter the end of the range: "))
random_number = generate_random_number(start, end)
print("Random number between", start, "and", end, "is:", random_number)

Example:

Enter the start of the range: 1

Enter the end of the range: 10

Random number between 1 and 10 is: 7

Example:

Enter the start of the range: 10

Enter the end of the range: 100

Random number between 10 and 100 is: 57

Code Explanation:

The function generate_random_number(start, end) takes the start and end of the range as input and returns a random integer within that range using Python's random.randint() function.

The example usage section demonstrates how to take input from the user for the range, generate a random number, and print the result.