Basic Programs

If Else Programs

While loop Programs

For loop Programs

List Programs


Python Program to Generate a Random Number


In this example shows, how to get character from the ACSII value using chr() method in python.

  • First, we import the random module.
  • The built-in function randint() used to generate random number in python.
example.py
# importing the random module
import random

#generate a random number between 0 and 100
print(random.randint(0,100))

#generate a random number between 1000 and 10000
print(random.randint(1000,10000))

Output

54
2090

Prev Next