How to Generate Random Number in Python

How To Generate Random Number In Python

In this python example, we are going to write a program to generate random number in Python.

Python is an interpreted, high-level and general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant whitespace.

A number is a mathematical object used to count, measure, and label. The original examples are the natural numbers 1, 2, 3, 4, and


so forth. Numbers can be represented in language with number words.

In common parlance, randomness is the apparent lack of pattern or predictability in events. A random sequence of events, symbols or steps often has no order and does not follow an intelligible pattern or combination.

random module is used in python for all the things related to random work. So we will also use that.

How to Generate Random Number in Python


# program to generate a random number between 0 and 9

# importing the random module
import random

print(random.randint(0,9))
  

Output

9

Output Image

How to Generate Random Number in Python

Comments