1/39
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
You can use a while loop to iterate through each item in a collection. (T/F)
T
A parameter list is a part of the function's definition. (T/F)
T
There can be conditions such that the code block inside of a while loop won't run. (T/F)
T
What is the type of condition in the following while statement:
while condition:
bool
str
int
float
bool
When a function call is encountered, the return address "RA" is established in its frame before jumping to the first statement of the function's body (T/F).
T
Of the following, what does a function not do
abstract away processes
break larger programs into smaller sub-programs
define new data types
define new data types
Function calls are expressions that evaluate to a specific data type. (T/F)
T
If the condition in a while statement evaluates to _____, the program enters the repeat block and evaluate the first statement of the repeat block. (T/F)
T
When a function definition is encountered, the code block inside that function is run. (T/F)
F
print() and return perform identical commands. (T/F)
F
If the condition in a while statement evaluates to _____, the program exits the repeat block and continues to the next statement at the same level of indentation as the while keyboard. (T/F)
F
Defining a function is the same as calling it.
F
def flyer (w: int, x: str) -> int:
y: int = w + len (x)
return y
Which line(s) is a return type declared?
1
def flyer (w: int, x: str) -> int:
y: int = w + len (x)
return y
List the name of the function defined.
flyer
def flyer (w: int, x: str) -> int:
y: int = w + len (x)
return y
On what line(s) are parameters found?
1
Write a line of code to call the function defined above with the arguemnts 3 and "plane".
flyer(3, "plane")
iteration
one pass through a while loop
often "i" (or "idx") is used as the counter to track the loop
The while statement allows you to repeat a block of statements in your program. (T/F)
T
The while statement is called a loop, because the control of your program jumps back up to a point earlier in the program that the end of the repeat block. (T/F)
T
The condition in the while statement's syntax must be a bool expression (T/F).
T
If the conidtion in a while statement evaluates to False, the program exits the repeat block and continues to the next statement at the same level of indentation as the while keyboard. (T/F)
T
If the condition in a while statement evaluates to True, the program enters the repeat block and dvalutes the first statement of the repeat block. (T/F)
T
After the final statement of the repeat block is evaluated, the program jumps back up to the condition of the while statement and evaluates it again. (T/F)
T
You can write any statements you'd like inside of the repeat block, such as other print statements, variable declaration and assignemnt statements, conditional if-else statements, while loop statements, and so on. (T/F)
T
To avoid an infinite loop which of the following should be true:
Something must change in the repeat block taht cause the while loop's condition to change.
Forward progress must be made toward the while loop condition becoming True.
Forward progress must be made toward the while loop condition becoming False.
1, 3
Your computer knows when you write an infinte loop in your program and will not run your program if it sees it is doing pointless, endless work on your behalf. (T/F)
F
The phrase "if loop" is incorrect and should not be said. The phrase "while loop" is correct. (T/F)
T
You can use a while loop to iterate through each item in a collection. For example, a str is a collection of characters, and you can use a while loop to reason about each character one-by-one. (T/F)
T
When iterating through a collection using the index/subscription operator, such as with a string, it is common to use your counter variable as the index operator's int value in order to access individual items in the collection one-by-one. (T/F)
T
The big, valuable idea of a loop is that it allows you to write a fixed number of lines of code that can process arbitrarily sized amounts of data and/or computations. (T/F)
T
Functions are used for which of the following:
- Process abstraction
- Defining new data types
- Breaking larger problems into smaller sub-programs (task decomposition)
Process abstraction
Breaking larger problem into smaller sub-programs
Defining a function is the same a calling it. (T/F)
F
A function definition can be thought of as a specfication of the instructions which will be carried out when the function is called. (T/F)
T
Function definitions are found in which of the following ways:
Built-in functions automatically avilable
Imported from libraries
Defined in the same python file/module
All the above
Which of the following will appear in a valid functiona call expression?
the def keyword
the name of the function
an argument list
a parameter list
a function body
the name of the function
an arugment list
Which of the following will appear in a valid functiona definition signature?
the def keyword
the name of the function
an argument list
a parameter list
a function body
a return type preceeded by ->
ends with a :
def keyword
name of the function
parameter list
a return type preceeded by ->
ends with a :
Which of the following will appear in a valid functiona definition?
the def keyword
the name of the function
an argument list
a parameter list
a function body
a return type preceeded by ->
ends with a :
signature
signature
Each argument is an expression. (T/F)
T
The signature line tells anyone who wants to use a function what it needs in order to be called and what you can expect returned back as a result. (T/F)
T
Parameters are found in function definitions. Arguments are found in fucntion calls. (T/F)
T