{'joe': 34, 'tom': 20, 'mary': 50}
PHOT 110: Introduction to programming
LECTURE 10: Data, Dictionaries and Pandas (Ch. 6)
Michaël Barbier, Spring semester (2023-2024)
A list of key-value pairs with unique keys
items()
, keys()
, and values()
extract key-value pairs, keys, and values of the dictionaryitems()
, keys()
, and values()
extract key-value pairs, keys, and values of the dictionaryitems()
, keys()
, and values()
extract key-value pairs, keys, and values of the dictionarySimilar to list comprehension:
[1, 4, 9, 16]
With dictionaries use curly brackets and the colon separator:
Lecture 10: Data, Dictionaries and Pandas (Ch. 6)