Concepts on Quiz 0
Before working through these practice questions, you should first carefully read this page on Quiz Expectations
Quiz 0 will cover the following concepts:
- Syllabus and course policies
- Lessons 0 through 7 (including the memory diagrams of LS07)
Questions
The quiz itself will be similar in difficulty but longer in length than these practice questions. Expect about 3x memory diagrams and around 30x other questions which follow.
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.
Data Types
str
literals in Python can be surrounded in either single-quote characters or double-quote characters, though in COMP110 we prefer the latter. (T/F)TRUE
andFALSE
are valid bool values in Python. (T/F)- An
int
literal can begin with a zero, but cannot end with a zero. (T/F) - What function can we use to identify the type classification of any object in Python?
- What is the resulting data type of the following expression?
int("20")
Expressions
- What is the evaluation of the following expression?
type(9 / len( str(110))
- What is the result of the following expression?
"440" + "20"
- What value of x would cause the following expression to evaluate to
True
?(3 + x) == (55 % 2 ** 4)
- What value does the following expression result in, and what is its type?
2 + 2 / 2 ** (2 * 0)
- Using subscription syntax and concatenation, write an expression that evaluates to
"tar"
using the following string:“the brown, lazy dog!"
. - What data type do expressions with relational operators evaluate to?
- What does the following expression evaluate to?
int("10" + "40") > 100 * 2
Solutions
Memory Diagrams
Data Types
- T
- F
- F
type()
- int
Expressions
<class 'float'>
- “44020”
- 4
- 4.0
- “the brown, lazy dog!”[0] + “the brown, lazy dog!”[12] + “the brown, lazy dog!”[5]
- bool
- True