Libraries - random Flashcards

1
Q

blue, yellow, red

Assign one of the colors above randomly to the variable “color”

A

import random

color = random.choice([“blue”, “yellow”, “red”])

random.choice() requires a “sequence”, e.g., List, Tuple, String, range()

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