Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
10 Cards in this Set
- Front
- Back
dictionary syntax |
{ key: value } |
|
What can you place in a dictionary? |
the order of the key-value pairs is irrelevant, and the keys must be immutable (no sets or lists or
+ tuples |
|
Indexing dictionary |
Just keys!
right
{4:"four", 3:'three'}[4] |
|
Testing membership |
'Oracle' in mydict |
|
.get() |
.get(key, default)
Testing membership and setting up a default error if its not found. |
|
Mutating dictionaries |
With the key
>>> mydict['Agent Smith'] = 'Hugo' |
|
dictionary ycomprehensions |
>>> { k:v for (k,v) in [(3,2),(4,0),(100,1)] } |
|
dictionary functions |
.keys() - gets the keys .values() - gets the values
| and &
|
|
| and & |
>>> [k for k in {'a':1, 'b':2}.keys() | {'b':3, 'c':4}.keys()] |
|
.items() |
Turns the dictionary key values into tuples
>>> [myitem for myitem in mydict.items()]
|