Concepts on Quiz 0
Quiz 0 will cover the following concepts:
- Lessons 0 through 7
- Challenge Questions 0 through 3
Format
Quiz 0 will be an untimed assessment. It is meant to be a practice for future quizzes, so that you may get used to the format, and receive feedback on how you are understanding the material so far. You will have from 9:00am until 11:59 to complete the quiz on Gradescope.
Questions
The quiz itself will be similar in difficulty but longer in length than these practice questions. In addition to these questions, you should review all of your lesson responses on Gradescope. The kinds of questions you responded to on Gradescope will also be on the quiz.
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
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)
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
Conditionals
- False
- False
- False