[Hint: definition]
function
What is ... a block of code that does one job?
[Hint: Definition]
variable
What is ... a box with a name that holds a value?
[Hint: Definition]
looping
What is ... when a computer executes (or runs) the same instructions (or commands or actions) over and over?
[Hint: Definition]
conditional
What is ... when a computer "makes a decision" depending on a condition or conditions?
# Hint: Definition. Not the output.
my_list = [1, 2, 3, "A", 5.1, True, [5, 6, 7]]
my_list[6] = "cat"
print(my_list)
# Output: [1, 2, 3, 'A', 5.1, True, 'cat']
What is ... a data structure that is ordered and mutable (i.e., a list)?
[Hint: Definition]
def
What is ... the Python keyword used to DEF-ine a function?
# Hint: The coding concept
egg = 3
Egg = 7
print(egg)
# Output: 3
What is ... case-sensitivity?
Or what is ... Python is a case-sensitive coding language?
# Hint: The output
for ham in range(5):
print(ham)
What is ... 0 1 2 3 4 ?
# Hint: The output
egg = 5
if egg == 5:
print("True")
What is ... True?
# Hint: The coding concept.
my_list = []
print(my_list)
# Output: []
What is ... the empty list?
[Hint: Definition]
return
What is ... the Python keyword used to code a return statement (or return statements) in a function (or method)?
# Hint: _____Error
5catsinthehouse = True
What is a ... SyntaxError?
# Hint: The coding concept.
# Not the output.
for ham in range(5):
print(ham)
What is ... a for loop?
# Hint: The output
egg = 7
if egg == 5:
print("True")
else:
print("False")
What is ... False?
# Hint: The coding concept.
# Not the output.
my_list = ["A", "B", "C"]
for spam in my_list:
print(spam)
What is ... looping through a list?
[Hint: This is an example of _____ vs. _____.]
def my_func(egg, spam):
vs.
my_func(5, 7)
What is ... the parameter vs. the argument?
Or what are ... parameters vs. arguments?
FYI: Parameters: egg and spam
Arguments: 5 and 7
# Hint: The output. Read carefully.
egg = 7
spam = 5
egg, spam = spam, egg
print(egg)
print(spam)
What is ... 5 7 ?
# Hint: The coding concept. Not the output.
egg = 0
while egg < 5:
print(egg)
egg += 1
What is ... a while loop?
# Hint: The output. Read carefully.
egg = 5
if egg == 5:
print("Five")
elif egg == 1:
print("One")
else:
print("Not 1 or 5")
What is ... Five?
[FYI: The code was tested with JDoodle.]
# Hint: The output. Read carefully.
listA = [4, 5, 6]
listB = [1, 2, 3]
listC = listB + listA
print(listC)
What is ... [1, 2, 3, 4, 5, 6]?
Or what is ... 1, 2, 3, 4, 5, 6?
[FYI: The code was tested with JDoodle.]
[Hint: Definition]
recursion
What is ... when a function calls itself?
# Hint: The output. Read carefully.
egg = "eggs"
eggs = "egg"
ham = "ham"
spam = "spam"
ham = egg
ham = spam
print(ham)
What is ... spam?
# Hint: The coding concept. Not the output.
spam = 1
while spam > 0:
print(spam)
spam += 1
What is ... an infinite loop?
# Hint: The output. Check the code carefully.
beans = 21
spam = ""
if (beans % 3) == 0:
spam += "Fizz"
if (beans % 5) == 0:
spam += "Buzz"
if spam == "":
print(beans)
else:
print(spam)
What is ... Fizz?
my_list = ["A", "B", "C"]
print(my_list[-2])
# Output: B
# Hint: The coding concept. Not the output.
# Check the code carefully.
What is ... negative indexing?
Or what is ... the second to last (i.e., penultimate) item?