Python Week 3
It doesn't matter.
What age would the user have to enter in order to see the part of the conversation regarding the likelihood of rain?
<=
Which of the following is a relational operator?
False, begins with #
A Python block comment begins with a double slash (//).
False
A Python comment cannot appear on a line that contains an executable statement.
False, some have no parameters
A Python function must have at least one parameter.
True
A character string can be used as the condition of an if statement.
True
A function can return a boolean result.
True
A while loop affects a program's flow of control.
'committee'
If a variable called word refers to the string 'committee', what is the result of the expression word.strip('m')?
False, one operand.
The not operator requires two operands.
True
A function parameter ceases to exist when the function returns to the caller.
Pseudocode
A language that is independent of any particular programming language. Check My Quick Check Answers Terms of Use
True
A pass statement can be used as the body of an if statement, for loop, function definition, or class definition.
True
After a function finishes executing, control returns to the place the function was called.
False
An assignment statement affects a program's flow of control.
False
An if statement cannot have both an elif and an else clause.
False
An if statement is used to process the user's thoughts on the meaning of life.
True
If A and B are both false, then the expression A and B is false.
True
If A is false, then the B operand in the expression A and B is not evaluated.
False, B must also be evaluated.
If A is false, then the B operand in the expression A or B is not evaluated.
True
If A is true and B is false, then the expression A or B is true.
2
If a variable called address refers to the string '123 Main Street', what is the result of the expression address.find('3')?
Returns a new string containing the characters 'HELLO'
If a variable called greeting refers to the string 'hello', what does the expression greeting.upper() accomplish?
False
If a variable called user_id refers to the string 'AEinstein12', what is the result of the expression user_id.isalpha()?
True
If the user input indicates that the likelihood of rain is 'certain', it will be treated as a negative response.
True
In Python, the relational operators can be used to put character strings in alphabetical order.
Age, from string to integer so it can be treated as a number.
In the conversation program, which input value was converted to another type after being entered by the user?
height = 15, size = 10, width = 110
Of the options given, what values of the variables height, size, and width would cause the following code to set the variable weight to 100? if height < size: weight = 50 if width < 20: print('short') else: if width > 100: weight = 100 println('tall')
True
Python comments begin with a hash mark (#) and extend to the end of the line.
False
The arithmetic operators have a lower precedence than the relational operators.
Input
The data needed by an algorithm to accomplish its task.
Output
The data produced by an algorithm.
True
The differences in case are ignored when processing the user's favorite band.
False
The less than operator (<) should not be used to compare floating point values.
True
Variables declared inside a function cannot be accessed from outside that function.
A character string used as a comment in a program.
What is a docstring?
The order in which statements are executed.
What is a program's flow of control?
Linear
What is the default flow of control through a function?
Mustard
What output is printed by the following code if it is executed when appetizer is 3 and entree is 12? if appetizer > 1: if entree < 7: print('ketchup') else: print('mustard') else: if appetizer < 0: print('mayonnaise') else: print('relish')
Mwasswassippi
What output would be produced when the following code is executed? state = 'Mississippi' print(state.replace('is', 'was))
The word collywobbles is not printed and processing continues.
What will happen if the variable total has the value 5 when the following code is executed? if total > 8: print('collywobbles')
a >= b
Which of the following expressions could be used to determine if a is not less than b?
The last statement in a function must be a return statement.
Which of the following is NOT true regarding the return statement?
The statements in the body of an if must be indented.
Which of the following statements is true?
13
Which value of num will cause the print statement in the following code to be executed? if num < 15: if num + 7 >= 20: print('There you go!')
Flowchart
A graphical representation of the logic of an algorithm.
Natural Language
A language that humans use to communicate, such as French or English.
Algorithm
A step-by-step procedure for solving a problem.
True
An if statement affects a program's flow of control.
True
A comment in a Python program is ignored by the interpreter.
Granularity
The level at which an instruction is expressed.
True
The pass statement has no effect on the program state.
False
The pass statement is useless.
True
The relational operators all return boolean results.
True
The result of a relational operator can be assigned to a variable.