Generating Random Number Using Random Module

Write a Python program that uses the random module to generate a random number between 0 and 100. Return the generated number.

Example:

Input: None
Output: Random number between 0 and 100

Use the randint() function from the random module.

import random

def generate_random():
    return random.randint(0, 100)

# Test the function
print(generate_random())  # Output: Random number between 0 and 100
print(generate_random())  # Output: Random number between 0 and 100

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!