Use randint when a program needs a random integer between two bounds. Its upper bound is inclusive, so random.randint(10, 30) can return 10 through 30, including both endpoints. section 1.2 section 1.3
Number guessing game
import random def guessing_game(): answer = random.randint(0, 100) while True: guess = int(input('Guess the number: ')) if guess < answer: print('Too low') elif guess > answer: print('Too high') else: print('Just right') break guessing_game() section 1.2 section 1.3
import random number = random.randint(10, 30)
Shows the minimal import-and-call pattern for assigning a random integer to a variable. section 1.2

