Quiz 01 Practice


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

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

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

Boolean Operators

  1. 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

  1. Every if statement must have a paired else branch. (T/F)
  2. Lines contained in an else branch in Python do not have to be indented. (T/F)
  3. You can name a variable else in your program without Python confusing your variable’s name and the else keyword. (T/F)
  4. Given the following code snippet, what is the printed output with the specified values for x and y?

    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

  1. Given the following code snippet, what is the printed output once it completes?

  2. Given the following code snippet, what is the printed output once it completes?

Solutions

Memory Diagrams

Boolean Operators

  1. 3.1. True
    3.2. True
    3.3. False
    3.4. False
    3.5. True

Conditionals

  1. False
  2. False
  3. False
  4. 7.1. 17.0
    7.2. 2.0
    7.3. -2.0
    7.4. 3.0
    7.5. 1.0

While Loops

  1. 3
    3
    “1303132”
  2. “036910875421”
Contributor(s): Megan Zhang, David Karash