+2 votes
in Python by (170 points)
Generate random integers between 0 and 9
In Python, How do I generate random integers between 0 to 9 ?

2 Answers

+2 votes
by (10.9k points)
edited by

@Ankita ,This is very simple ,just use the random.randint(x,y):

It returns random integers M such that randrange(x,y+1) , where x <= M <= y .

Use this code to generate random int between 0 to 9:

from random import randint

print(randint(0, 9))

Hope this answer helps.

0 votes
by (107k points)

import random


random.randint(a, b)

This returns a random integer N such that a <= N <= b.

You can use the following video tutorials to clear all your doubts:-

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Jul 2, 2019 in Python by ParasSharma1 (14.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !