1/244
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
What is a bool data type in Python?
A data type for storing True/False values.
What is an int data type in Python?
A data type for storing whole numbers, such as -10, 3, or 100.
What is a str data type in Python?
A data type for storing text.
What is a float data type in Python?
A data type for storing numbers with decimals, such as 1.0, 3.14, or -0.1.
Can an int literal begin with any number of zeroes in Python?
No
Which function determines the type of an object in Python?
type()
What does len() do in Python?
Returns the length of a sequence, such as a string or list.
What does int() do to a float?
It removes/truncates the decimal part.
What does str() do?
Converts a value into a string.
What does the % operator do?
Returns the remainder after division.
What does 102 % 5 evaluate to?
2.
What does "110" + "110" evaluate to?
"110110"
What does "hehe" * 2 evaluate to?
"hehehehe".
What does "map"[1] evaluate to?
"a"
What index does Python start with?
0.
What does "12345"[len("12345") - 1] evaluate to?
"5".
What does str(3.0 + 3.0) evaluate to?
"6.0".
What does 4 % 2 evaluate to?
0.
What does int("5" + "4") + 54 evaluate to?
108.
What does int(3.8 + 1) evaluate to?
4.
What type does 1.5 + 2 evaluate to?
float.
What value does 1.5 + 2 evaluate to?
3.5.
What type does len("cottage") evaluate to?
int.
What value does len("cottage") evaluate to?
7.
What type does "True" evaluate to?
str, because the quotes make it a string.
What type does len("Pet") > 2 evaluate to?
bool.
What value does len("Pet") > 2 evaluate to?
True.
What type does 2.0 + 2 ** 2 evaluate to?
float.
What value does 2.0 + 2 ** 2 evaluate to?
6.0.
What does str(110) * 2.1 evaluate to?
TypeError, because strings can be multiplied by ints, not floats.
What does float("100.0") / 20 evaluate to?
5.0.
What does 21 // 2 ** 2 + 3 evaluate to?
8.
What does float("220") >= float("100" + "100") evaluate to?
False.
What does int("COMP 110"[5]) + 99.0 evaluate to?
100.0.
What does (42 % 4) == (79 % 11) evaluate to?
True.
What does int(4.99) evaluate to?
4.
Which operator concatenates two strings?
+.
What is a function definition?
Code that creates/specifies a function, including the signature and indented body.
What is a function call?
Code that invokes/executes a function by writing the function name followed by parentheses.
Is defining a function the same as calling it?
No
Does defining a function run the function body?
No. The body runs only when the function is called.
Are function calls expressions that evaluate to a specific data type?
Yes
When a function is called, where is its frame added?
The stack.
In a memory diagram, where are function names stored?
The stack.
What is output in a memory diagram?
The area where printed values appear.
What is a function signature?
The first line of a function definition with def, function name, parameters, parameter types, and return type.
Why is a function signature important?
It tells users what inputs the function needs and what type of value it returns.
What is a parameter?
A variable listed in the function signature that represents an expected input.
What is an argument?
The actual value passed into a function when it is called.
Are arguments used in function calls?
Yes
What is a return type?
The type annotation after the arrow -> in a function signature.
What does return do?
Ends the function and sends a value back to where the function was called.
What does print() do?
Displays a value in output but does not return that value.
Are print() and return identical?
No
What happens if a function has no return statement?
It returns None by default.
What does the return address, or RA, specify?
The line of code where execution returns after the function finishes.
Given def pet(w: str, x: str) -> int:, what is the function name?
pet.
Given def pet(w: str, x: str) -> int:, what are the parameters?
w and x.
Given def pet(w: str, x: str) -> int:, what are the parameter types?
Both are str.
Given def pet(w: str, x: str) -> int:, what is the return type?
int.
Given def pet(w: str, x: str) -> int:
return len(w) + len(x)
what does pet("Louie", "Sami") return?
9.
What is the signature for a function total that takes two floats num1 and num2 and returns a float?
def total(num1: float, num2: float) -> float:
What is the signature for a function get_char that takes a str word and int index and returns a str?
def get_char(word: str, index: int) -> str:

What is the result of the following function call? evaluate_length("airplane")
8.
What is the signature for pos_or_neg taking int number and returning str?
def pos_or_neg(number: int) -> str:
What is the signature for gcd taking two ints num_one and num_two and returning int?
def gcd(num_one: int, num_two: int) -> int:
What is control flow?
The order in which statements are evaluated or executed.
What is the standard mode of control flow?
Linear (top to bottom)
What does a conditional statement allow?
It lets a program choose which code block to run based on a condition.
Does every if statement need an else?
No
What type should an if condition evaluate to?
bool.
What must an if condition evaluate to in order to enter the then block?
True.
What must an if condition evaluate to in order to enter the else block?
False.
In an if/elif/else structure, can multiple branches run in the same pass?
No. Only one matching branch runs
Can you name a variable else in Python?
No. else is a reserved keyword.
What happens when return is encountered inside an if block?
The function immediately exits and returns that value.
What is the order of boolean operations for not, and, or?
not first, then and, then or.
What does and require to be True?
Both sides must be True.
What does or require to be True?
At least one side must be True.
What does not do?
Flips True to False or False to True.
What does (not False or True) and False evaluate to?
False.
What does (True and False) == (True and True) evaluate to?
False.
What does not (False or False) and (8 == 8) evaluate to?
True.
What does (False and False) or (10 <= 8) evaluate to?
False.
What does (not False) and True == True evaluate to?
True.
What does (not False) or (True and False) evaluate to?
True.
What does True and (7 < 3 * 4 / 6) evaluate to?
False.
What does (not False) != True evaluate to?
False.
What does not (True and False) and (False or not False) evaluate to?
True.
What does "XYZ" == "XYZ" or "B" == "C" evaluate to?
True.
What does 5 ** 2 >= 5 * 5 and 110 % 10 == 0 evaluate to?
True.
What is recursion?
A function calling itself.
What is the base case in recursion?
The case that stops recursion and does not call the function again.
What is the recursive case in recursion?
The case where the function calls itself with a changed argument.
What is the purpose of the recursive case?
To progress toward the base case.
What happens if a recursive function has no base case?
It enters infinite recursion until Python raises RecursionError.
What error can occur from recursion with no base case?
RecursionError.
What must a recursive function have to avoid infinite recursion?
A base case, a recursive case that progresses toward it, and changing arguments.
Does simply calling itself guarantee recursion will stop?
No. It must progress toward a reachable base case.
What is a local variable?
A variable declared inside a function that only exists in that function’s frame.