3.2.9 - Random number generation in a programming language Flashcards

(3 cards)

1
Q

Generate a random integer between 1 and 10 in Python?

A

import random
number = random.randint(1, 10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Random number generation pseudocode?

A

number ← RANDOM_INT(1, 10)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Dice roll

A

import random
dice_roll = random.randint(1, 6)
print(“You rolled a”, dice_roll)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly