Created
October 21, 2022 15:41
-
-
Save mh0w/8e135bc33679b3fa1f4fa4566b0c81eb to your computer and use it in GitHub Desktop.
random sample from a dictionary (dict)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# Set seed for replicable results | |
random.seed(3210) | |
d = {'math': 99, 'english': 80, 'chemistry': 67, 'biology': 88, 'physics': 93} | |
dict(random.sample(d.items(), 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment