Python | Generate Random Number

For generating random numbers in Python Programming Language, Python’s Random Module function randint(a, b) can be used. Where a, b are some integers and randint function will pick up some random number from range a to b(Both including as well).
Like randint(4, 7) function may return any integer from 4 to 7, it can be 4 or 5 or 6 or 7.

Generating Random Numbers Using Python

# Generating random numbers using Python

import random

random_number = random.randint(10, 23)

print("Random number is =>", random_number)

Output of Above Code

Random number is => 22

More about Random Module => Python’s Random Module Documentation

Gagan

Hi, there I'm founder of ComputerScienceHub(Started this to bring useful Computer Science information just at one place). Personally I've been doing JavaScript, Python development since 2015(Been long) - Worked upon couple of Web Development Projects, Did some Data Science stuff using Python. Nowadays primarily I work as Freelance JavaScript Developer(Web Developer) and on side-by-side managing team of Computer Science specialists at ComputerScienceHub.io

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts