List Methods A
List Methods B
Random
Lists 101
Misc. (not list-related)
100

[Hint: Definition]

The append() method

What is ... "adds an element at the end of the list"?

[Source: W3Schools]

100

[Hint: Definition]

The pop() method

What is ... "removes the element at the specified position" (by default, the last item)?

[Source: W3Schools]

100

To clear a list

What is ... use the clear() method?

100

# Hint: The coding concept

my_list = []

What is ... the empty list?

100

[Hint: Definition]

OOP

What is ... Object-Oriented Programming?

200

[Hint: Definition]

The sort() method

What is ... the list method that "sorts the list (ascending by default)"?

[Source: W3Schools]


200

 [Hint: Definition]

The remove() method

What is ... "removes the first occurrence of the element with the specified value"?

[Source: W3Schools]

200

# Hint: The coding concept

a = []

b = a.copy()


What is ... how do you create a copy of a list?

Or how do you create a copy of a list?

200
len() is a ??? and not a ???.

What is ... "a function and not a method"?

200

Factory is to car as _____ is to _____.

Blueprint is to bridge as _____ is to _____.

What is ... class is to object?

300

To make the list method sort() sort in descending order

What is ... reverse = True?

300

# Hint: The output

list = ['apple', 'banana', 'carrots']

list.pop(2)

print(list)

What is ... apple, banana?

[FYI: The code was tested with PythonTutor.]

300

Lists are important because ... 

What is ... lists can store multiple data items of the same data type (or different data types) that are related?

300

# Hint: The output

my_list = ["bat", "cat", "hat"]

print(my_list[3])

What is ... the IndexError?

[FYI: The code was tested with PythonTutor.]

300

Is like a function but is not a function

What is ... a method?

400

To sort strings in a list from biggest to smallest lengths

What is ... specify (key=len, reverse = True)?

400

# Hint: The Output

list = ['apple', 'banana', 'carrots']

list.remove(1)

print(list)

What is ... the ValueError?

[FYI: The code was tested with PythonTutor.]

400

# Hint: Not the output

my_string = "!skcor nuH .rM"

my_string = my_string[::-1]

print(my_string)

What is ... the "secret formula" to reverse a string (in Python)?

Or how do you reverse a string (in Python)?

400

# Hint: The output

my_list = ["bat", "cat", "hat"]

print(my_list[-1])

What is ... hat?

Or what is ... the last item (in the list)?

Or what is ... negative indexing?

[FYI: The code was tested with PythonTutor.]

400

[Hint: Keyword]

class

What is ... the (Python) keyword used to define (or to create) a class?

500

# Hint: The output

list = ['apple', 'banana', 'carrots']

list.append('celery')

list.sort(key = len, reverse = True)

print(list)

What is ... carrots, banana, celery, apple?

[FYI: The code was tested with PythonTutor.]

500

# Hint: The output

list = ['apple', 'banana', 'carrots', 'mango', 'pear']

list.remove('apple')

list.pop(3)

print(list)

What is ... banana, carrots, mango?

[FYI: The code was tested with PythonTutor.]

500

# Hint: Not the output. What the code does.

my_list = ["Lenny", "Joey", "Danny"]

if "Lenny" in my_list:

    print("'Lenny' is in the list")

What is ... how to check if an item (or element) is in a list?

[FYI: The code was tested with PythonTutor.]

500

# Hint: The output

my_string = "Eggs, spam, ham, beans"

my_string.reverse()

print(my_string)

What is ... the AttributeError?

Or what is ... "Python has no built-in string reverse() function or method"?
[FYI: The code was tested with PythonTutor.]

500

[Hint: Definition] self

What is ... the parameter that refers to the instance (or object) calling the method?

Click to zoom
M
e
n
u