Concepts on Quiz 1
Before working through these practice questions, you should first carefully read this page on Quiz Expectations.
Quiz 1 will cover the following concepts:
- Lessons 8 through 12
Questions
The quiz itself will be similar in difficulty but longer in length than these practice questions.
Solutions for each problem can be found at the bottom of this page.
Memory Diagrams
Produce a memory diagram for the following code snippet, being sure to include its stack and output.
Produce a memory diagram for the following code snippet, being sure to include its stack and output.
Boolean Operators
- What is the result of the following boolean expressions?
3.1.((not False) and True) == True
3.2.(not False) or (True and False)
3.3.True and (7 < 3 * 4 / 6)
3.4.(not False) != True
3.5.not(True and False) and (False or not False)
Conditionals
- Every
if
statement must have a pairedelse
branch. (T/F) - Lines contained in an
else
branch in Python do not have to be indented. (T/F) - You can name a variable
else
in your program without Python confusing your variable’s name and theelse
keyword. (T/F) - Given the following code snippet, what is the printed output with the specified values for
x
andy
?
7.1. When x = 3, y = 5?
7.2. When x = 5, y = 3?
7.3. When x = -5, y = 1?
7.4. When x = 13, y = 8?
7.5. When x = 4, y = 3?
While Loops
Given the following code snippet, what is the printed output once it completes?
Given the following code snippet, what is the printed output once it completes?
Solutions
Memory Diagrams
Boolean Operators
- 3.1.
True
3.2.True
3.3.False
3.4.False
3.5.True
Conditionals
- False
- False
- False
- 7.1. 17.0
7.2. 2.0
7.3. -2.0
7.4. 3.0
7.5. 1.0
While Loops
- 3
3
“1303132” - “036910875421”