Week 5: Mouse input, dictionaries and images Flashcards
What does list.index(x) do?
Shows what “X” is in the list which is being indexed
What does list.append(x) do in Python?
Adds “x” to the end of the list being appended
What does list.pop(X) do in Python?
Removes “x” from the list being referenced. If no argument is given then it will remove the last item on the list.
Can a list in Python be modified while it is iterating?
No, if it is modified while iterating then it may lead to unpredictable behaviour
What is a Dictionary in Python?
Dictionaries are a way of “mapping” in Python. eg. Keys to Values {1:2} - 1 would be the key, and 2 would be the value; keys are commonly numbers or strings; values have more variety