Podcast
Questions and Answers
What does the list method insert(i,x) do?
What does the list method insert(i,x) do?
- Appends item x to list y
- Inserts item x to list y at position i (correct)
- Deletes item x from list y
- Returns the number of times x appears in list y
What does the list method remove(x) do?
What does the list method remove(x) do?
- Removes the first item from list y that has a value of x (correct)
- Inserts item x to list y at the front
- Appends item x to list y
- Deletes item x from list y
What does the del statement do in Python when used with a list?
What does the del statement do in Python when used with a list?
- Appends a new item to a list
- Deletes an item in a list (correct)
- Reverses the items in a list
- Sorts the items in a list
What error is raised when trying to access an index out of bound in a list?
What error is raised when trying to access an index out of bound in a list?
What is the output of the code 'print('a b c'.split())'?
What is the output of the code 'print('a b c'.split())'?
What does the expression len(['p', 's', 'y']) return?
What does the expression len(['p', 's', 'y']) return?
What does the code 2 * ['a'] produce?
What does the code 2 * ['a'] produce?
What does the method remove() do for a list?
What does the method remove() do for a list?
Which function is used to find the number of elements in a list?
Which function is used to find the number of elements in a list?
What does the expression ['add', 'class', 'contains', 'delattr'] represent?
What does the expression ['add', 'class', 'contains', 'delattr'] represent?