How do i use the randint module in python?

Introduction

In this tutorial, we are going to focus on the randint[] method in Python. In our previous tutorials, we saw different random number generating methods defined inside the random module in our Random Number Tutorial in Python.

So, as you already know, we need to import the random module in Python first to begin using the randint[] method. The module essentially creates pseudo-randomness.

The randint[] method Syntax

Basically, the randint[] method in Python returns a random integer value between the two lower and higher limits [including both limits] provided as two parameters.

It should be noted that this method is only capable of generating integer-type random value. Take a look at the syntax so that we can further incorporate the method.

#randint[] Syntax
randint[lower limit , upper limit]

Here,

  • lower limit is the starting point from and including which the random integer would be generated,
  • uppwer limit is the stopping point up to which the method would return the random integer.

The above example returns an integer N where N>=beg and N

Chủ Đề