Jed Rembold & Fred Agbo
March 3, 2025
Comparatively speaking, how would you say you are doing in absorbing and keeping up with the material in this class?
Created using square brackets with elements separated by commas:
COIN_VALUES = [1, 5, 10, 25, 50, 100]
COIN_NAMES = [ "penny", "nickle", "dime",
"quarter", "half-dollar", "dollar" ]
Lists are commonly represented visually or conceptually as a series of numbered boxes:
Can retrieve the value of any element in a list by writing the index of that element in square brackets after the list name
COIN_VALUES[3]
⟶
25
COIN_NAMES[2]
⟶
"dime"
Can concatenate two lists to form a new list with elements from both
[1,2,3] + [4,5,6]
⟶
[1,2,3,4,5,6]
Can loop through each of the list elements in turn
for elem in my_list:
# do stuff with elem
where elem
is the name of the variable
that will sequentially get assigned the value of every element in
my_list
len
function+
or
+=
*
in
operatorWhat would the below expression evaluate to?
[“One”, 2, True][-1:1:-1][1]
"n"
2
True