



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive set of true/false questions and exercises focused on while loops and boolean expressions in python programming. it tests understanding of loop control, boolean logic, and common programming concepts. The quiz is suitable for students learning introductory programming and includes detailed answers for self-assessment.
Typology: Exams
1 / 27
This page cannot be seen from the preview
Don't miss anything!




















True or False: The while statement allows you to repeat a block of statements in your program. - Precise Answer ✔✔- True
True or False: The while statement is called a loop because the control of your program jumps back up to a point earlier in the
program than the end of the repeat block. - Precise Answer ✔✔- True
True or False: You can name a variable while in your program without Python confusing your variable's name and the while
keyword. - Precise Answer ✔✔- False
True or False: The condition in the while statement's syntax must be a bool expression. - Precise Answer ✔✔- True
True or False: If the condition in a while statement evaluates to False, control jumps over the repeat block and onto the next statement at the same level of indentation as the while keyword.
True or False: If the condition in a while statement evaluates to True, control jumps into the repeat block and evaluates the first
statement of the repeat block. - Precise Answer ✔✔- True
True or False: After the final statement of the repeat block is evaluated, control jumps back up to the condition of the while
statement and evaluates it again. - Precise Answer ✔✔- True
True or False: You can write any statements you'd like inside of the repeat block, such as other print statements, variable declaration and assignment statements, conditional if-else statements, while loop statements, and so on. - Precise Answer ✔✔- True
To avoid an infinite loop which of the following should be true, choose all that apply:
condition becoming False. - Precise Answer ✔✔- Something must change in the repeat block that causes the while loop's condition to change.
True or False: 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 iterate through each
character one-by-one. - Precise Answer ✔✔- True
True or False: The variable i is commonly used as a counter variable when writing while loops. You can choose other variable names instead, though. For example, counter could have been used as the variable name instead. - Precise Answer ✔✔- True
True or False: 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. -
Precise Answer ✔✔- True
True or False: 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. - Precise
Answer ✔✔- True
What is the result of the following boolean expression?
not True
What is the result of the following boolean expression?
not not True
What is the result of the following boolean expression?
not True and not True
What is the result of the following boolean expression?
not True or not False
Which operator evaluates first?
Consider the following expression:
True and False or False and not False
Which operator evaluates last?
Evaluate the function: not True - Precise Answer ✔✔- False
Evaluate the function: not False - Precise Answer ✔✔- True
Evaluate the function: True and True - Precise Answer ✔✔- True
Evaluate the function: True and False - Precise Answer ✔✔- False
Evaluate the function: False and False - Precise Answer ✔✔- False
Evaluate the function: True or True - Precise Answer ✔✔- True
Evaluate the function: True or False - Precise Answer ✔✔- True
Evaluate the function: False or False - Precise Answer ✔✔- False
Rank these relational operators in terms of precedence, from first to last.
What does the following expression evaluate too?
True or False: The reason why the answer for the previous two questions are the same is because when you compare two strings the ordinal (ord) values of each character are compared. -
Precise Answer ✔✔- True
What is the result of evaluating chr(129313)?
How many digits are there in hexadecimal ("hex") numbers?
The largest hex digit is F. What is its value in the decimal system?
True or False: The following string uses an escape sequence that causes it to span multiple lines when printed?
"Hello\nworld\n!!!" - Precise Answer ✔✔- True
True or False: Function calls are expressions that evaluate to a specific data type. - Precise Answer ✔✔- True
True or False: When you define a function you are invoking its call. - Precise Answer ✔✔- False
True or False: A function definition can be thought of as a sub- program that specifies the instructions which will be carried out
when the function definition is called. - Precise Answer ✔✔- True
Function definitions are found in which of the following ways:
True or False: Functions in programming are exactly equivalent to algebraic functions. - Precise Answer ✔✔- False
What are the syntax requirements of a valid function call expression?
True or False: Each argument is an expression. - Precise Answer ✔✔- True
A function definition is made of which of the following high- level elements?
True or False: Parameters are found in function definitions.
Arguments are found in function calls. - Precise Answer ✔✔- True
True or False: A parameter list is made of a pair of matching parentheses with a list of "variable declaration" statements separated by commas found between them, which specify the
parameters of the function. - Precise Answer ✔✔- True
When tracing a program to produce a memory diagram, much like the Python interpreter processes a program, and a function definition statement is encountered, what happens in our memory diagram? Choose all that apply.
What steps are needed to prepare for a function call when tracing a program?
definition. - Precise Answer ✔✔- Check for the name of the function being defined.
When function call expressions are evaluated, new frames are added to which area of the memory diagram?
True or False: The current frame of evaluation is the lowest
frame on the stack that has yet to return. - Precise Answer ✔✔- True
True or False: When determining the value of a variable access expression you must first look in the current frame of evaluation
on the stack. - Precise Answer ✔✔- True
What happens when a return statement is evaluated while tracing through a call to a function definition?
True or False: The expression following the return keyword must evaluate to a value whose data type matches the return type specified in the signature line of its function definition. - Precise
Answer ✔✔- True
What is improper about the following function definition?
def hello)n(n: int) -> int:
"""A silly example function.""" return "hello " + str(n)
print(hello_n(3))