Python Programming Examples Tutorial Index

Python Number Programs


This Python example code demonstrates a simple Python program to generate a random number. This program uses the Python Random module, an in-built module of Python used to generate random numbers.

Program:

#Import the required modules
import random

#Print the output
print(random.randint(0000,9999))

Program Output:

7915

Random numbers are helpful when the program needs them for some reason, such as sending OTP.