A tuple is an immutable, sequential data structure that can be of different data types.
What is a tuple?
This is a mutable data structure that holds ordered collection of data items.
What is a list?
The purpose of a for loop in Python.
What is to iterate over a sequence (like a list, tuple, or string) and execute a block of code each time?
This is method would you use to add several items to the end of a list.
What is extend () ?
A reusable block of code that performs a specific task and can take inputs, known as parameters, and return an output.
What is a function?
Placing a comma-separated list of values inside parentheses, like this: (1,2,3).
What is defining a tuple?
This is created when using empty square brackets like this [].
What is an empty list in Python?
The output of the following code?
my_list = [1, 2, 3, 4]
for num in my_list:
print(num * 2)
What is
2
4
6
8
This method takes out the first occurrence of a specified value from a list.
What is the remove () method?
This keyword is used to define a function in Python.
What is def?
The output of the following code: my_tuple = (1, 2, 3); print(my_tuple[1])?
What is 2 (because indexing in Python starts at 0)?
The output of the following code: my_list = [1, 2, 3]; print(my_list[2])
What is 3 (because indexing in Python starts at 0)?
This is the technique used to access the last element of a list.
What is -1 ?
This method would you use to sort a list in ascending order.
What is the sort() method?
This is the output for the following code:
def greet(name):
return "Hello, " + name
print(greet("Alice"))
What is "Hello, Alice"?
The reason you cannot modify an element in a tuple.
What is immutable?
The list method you would use to add an item to the end of a list.
What is the append() method?
The output of the following code?
fruits = ['apple', 'banana', 'cherry']
for fruit in fruits:
print(fruit[0])
What is
a
b
c
This method would be used to change to order of elements in a list from front to back?
What is the reverse() method changes the order of elements in a list?
The output of the following code is:
def add(x, y):
return x + y
print(add(3, 5))
What is 8?
The difference between a tuple and a list in Python.
What is lists are mutable and use square brackets?
(Tuples use parenthesis).
The method you can use remove an item from a list by value.
What is using the remove() method? For example, my_list.remove(value).
This is how you would combine two lists together into one list.
What is combine the lists using the + operator:
combined_list = list1 + list2
The output for the following code:
numbers = [5, 3, 9, 1]
numbers.sort(reverse=True)
print(numbers)
What is
[9,5,3,1]
This is the syntax to call a function named my_function?
What is my_function() ?