Quiz 00 Practice


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

  1. Produce a memory diagram for the following code snippet, being sure to include its stack and output.

  1. Produce a memory diagram for the following code snippet, being sure to include its stack and output.

Data Types

  1. 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)
  2. TRUE and FALSE are valid bool values in Python. (T/F)
  3. An int literal can begin with a zero, but cannot end with a zero. (T/F)
  4. What function can we use to identify the type classification of any object in Python?
  5. What is the resulting data type of the following expression? int("20")

Expressions

  1. What is the evaluation of the following expression? type(9 / len( str(110))
  2. What is the result of the following expression? "440" + "20"
  3. What value of x would cause the following expression to evaluate to True? (3 + x) == (55 % 2 ** 4)
  4. What value does the following expression result in, and what is its type? 2 + 2 / 2 ** (2 * 0)
  5. Using subscription syntax and concatenation, write an expression that evaluates to "tar" using the following string: “the brown, lazy dog!".
  6. What data type do expressions with relational operators evaluate to?
  7. What does the following expression evaluate to? int("10" + "40") > 100 * 2

Solutions

Memory Diagrams

Data Types

  1. T
  2. F
  3. F
  4. type()
  5. int

Expressions

  1. <class 'float'>
  2. “44020”
  3. 4
  4. 4.0
  5. “the brown, lazy dog!”[0] + “the brown, lazy dog!”[12] + “the brown, lazy dog!”[5]
  6. bool
  7. True
Contributor(s): Megan Zhang, David Karash