Dictionary
Lists
General
100

What is a dictionary in Python?

A collection of key-value pairs.

100

What is a list in Python?


A list is an ordered collection of items that can be changed (mutable).


100

A collection that is ordered and can change

List

200

How do you access a value in a dictionary?

Use its key, like dictionary[key].

200

How do you create a list with three numbers: 1, 2, and 3?

my_list = [1, 2, 3]

200

A collection that is ordered but cannot change?

Tuple

300

What is the result of this code?

my_dict = {"name": "Alice", "age": 12}
print(my_dict["age"])

12

300

What method do you use to add an item to the end of a list?

append()

300

A collection where each item has a unique key?

Dictionary

400

How do you add a new key-value pair to a dictionary?

dictionary[new_key] = value.

400

How can you remove an item from a list by its value

remove()

400

 What method would you use to add an item to a list at a specific index?

insert()

500

Can a dictionary have duplicate keys?

No, keys in a dictionary must be unique

500

What does the following code print:

my_list = [10, 20, 30, 40]
print(my_list[1:3])


[20, 30]

500

How do you create a copy of a list?

list.copy() or list[:]