1/20
Flashcards about List Comprehension and 2D Lists in Python.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
parentheses
A tuple is created by enclosing a comma separated list of values between _.
TypeError
Trying to change a value inside a tuple will raise a _ because tuples do not support assignment.
tuple()
The built in _ function can create a tuple from another sequence.
tuple()
The _ function will create a tuple from any sequence.
packer
Open your activities module and add a function called _ that returns at least 4 values of your choice.
list()
Using the built-in _ function that will return any sequence as a list, e.g. a = list(range(10))
list()
Calling the _ function will return any sequence as a list
swapper
Open your activities module and add a new function named _ that declares a parameter for a_list.
[:]
Slicing uses a special operator, _, to create a new list by selecting specific values from an existing list.
start
If _ is omitted, it defaults to 0.
stop
If _ is omitted, it defaults to length.
chunky
Open your activities module and add a new function called _ that declares parameters for a_list and a size.
sort()
Calling the _ function on a list will perform an in- place sort on the values in the list.
sorted()
Calling the _ function will return a sorted copy of the list passed in as a parameter to the function
reverse
Setting the named _ parameter to True will sort the list in reverse order.
comprehension
List _ is a syntactic shortcut that can be used to copy the elements of any sequence into a list.
comprehension
Open your activities module and add a function named _.
2D
A _ list is simply a list of lists.
make_table
Open your activities module and add a new function named _ that declares parameters for rows, columns, and a default value.
tictactoe.py
Create a new Python module in a file named _ and add a function called “make_board” that creates and returns a Tic-Tac-Toe board.
make_move
Open your tictactoe module and add a function called _ that declares a parameter for the board and the current symbol (i.e. "X" or "O")