50. Dictionnary Flashcards

1
Q

what is a dict?

A
  • it is a data structure ( a way to organize data)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how can you organize data with dict ?

A

name = {
‘key’ : value,
}

print(name[‘b’’])

it prints the value

name is used as dictionary

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

A dictionary can be___.

A

scattered

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

what are it’s benefits vs a list?

A
  • you can use boleans, strings, and lists :), and assign them to a letter
  • ## ‘a’:…..
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how do you print the first line of the code if it looks something like this:

my_list = [
{
‘a’: [1,2,3]
‘b’: ‘hello’,
},
{
‘a’: [4,5,6],
‘b’: ‘hello’,
‘x’: True
}
]

A

print(my_list[0] [‘a’][2])

this means that
0 is the first item, ‘a’ is the key, and 2 is the second key

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