If:
x = [0,1,4,"turtle"],
then x[2] will return this.
What is 4?
If:
fav_players = {'Ben': 'Sock',
'Brendan': 'Paul',
'Coach Liam': 'Safin',
'Cole': 'Sharapova',
'Michael': 'Nadal',
'Nico': 'Kyrgios',
'Tucker': 'Monfils'}
then fav_players[3] will return this.
What is KeyError: 3? ("What is an error?" is also an acceptable answer)
What is "def forehand()"?
If specific instances of classes are like loaves of bread, then classes themselves are like these.
What are ovens?
The word for an element's position in a list.
What is an index?
If
dogs = {
"Onyx" : ["Black", "Large", "Medium-length Fur"],
"Lyla" : ["Black", "Medium", "Short Fur"],
"Bodie" : ["Brown", "Large", "Short Fur"]
}
then dogs["Onyx"][2] will return this.
What is "Medium-length Fur"?
A word for what goes in the parentheses of a function.
What is input, argument, or parameter?
Classes can have methods and these.
What are attributes?
If:
animals = ["fish", "baboon", "turkey", "vulture"]
then animals[2:4] will return this.
What is ["turkey", "vulture"]?
The kinds of pairs that dictionaries store.
What are key:value pairs?
A function doesn't have to have on of these, but if you want to store anything the function produces, it must.
What is a return statement?
This very common class method sets up starting characteristics of any instantiation of that class.
What is __init__()?
Lists are this, while tuples are not.
What is "mutable"?
dict = {
"Rafa" : "Lefty",
"Fed" : "Righty",
"Marcelo Rios" : "Lefty",
"Safin" : "Righty"
}
then
for key in dict.keys():
if dict[key]=="Lefty":
print(key)
will return this.
What is "'Rafa', 'Marcelo Rios'"?
If
def testfunction():
x = 5
y = [10, 6, 4]
return x, y
p, q = testfunction()
then q[1]/2 is this.
What is 3?
What is self?
If
test_scores = [95, 96, 92, 100, 94]
then test_scores[1:-1] will return this.
What is [96, 92, 100]?
dict = {
"dogs" : ["German Shepard", "Border Collie", "Labrador"],
"cats" : ["Tabby", "Calico", "Black"]
}
then this is how you would add "Schnauzer" listed dog breeds.
What is dict["dogs"].append("Schnauzer")?
If
def change_me(v):
print ("function got:", v)
v = 10
print ("argument is now:", v)
then the following block of code will return this.
myvar = 5
print ("starting with:", myvar)
change_me(myvar)
print ("ending with:", myvar)
What is
"starting with: 5
function got: 5
argument is now: 10
ending with: 5"?
If
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
and
p1 = Person("John", 36)
then we'd write this to show John's age.
What is print(p1.age)?