Practice mode Python

Which values can random.randint(1, 6) return?

Correct answer D. Any integer from 1 to 6, including both 1 and 6

Explanation

random.randint(a, b) returns an integer N with a <= N <= b, so both end points are included. This differs from range() and random.randrange(), which exclude the stop value. randint(1, 6) is therefore a fair way to simulate a six-sided die.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.