← Back to the Introduction to Computer Science outline The Course Maker
← Introduction to Computer Science outline
Week 10 · Quiz

Week 10 Quiz

Introduction to Computer Science Free sample edition
The student view of the 10-question quiz: each question and its options as they appear in Canvas. The answer key and the feedback ship only inside the course's .imscc (Classic QTI); they are not shown on this public page.
  1. Predict, then check: what does this program print?

    trip = ("Dock 4", "Dock 9", 12)
    print(trip[2])

    Select one.

    • 12
    • Dock 9
    • 3
    • TypeError
  2. Predict, then check: what happens when this program runs?

    spot = (3, 4)
    spot[0] = 9
    print(spot)

    Select one.

    • It prints (9, 4)
    • It stops with TypeError and prints nothing
    • It prints (3, 4)
    • It prints 9 4
  3. Predict, then check: what does this program print?

    a = 1
    b = 2
    a, b = b, a
    print(a, b)

    Select one.

    • 1 2
    • 2 2
    • 2 1
    • 1 1
  4. Predict, then check: what does this program print?

    log = {"river book": 120, "atlas": 85}
    log["field notes"] = 40
    log["atlas"] = log["atlas"] + 15
    print(log["atlas"])

    Select one.

    • 85
    • 15
    • 40
    • 100
  5. Predict, then check: what does this program print?

    log = {"atlas": 85}
    print(log["comics"])

    Select one.

    • KeyError
    • None
    • 0
    • 85
  6. Predict, then check: what does this program print?

    log = {"river book": 120, "atlas": 85}
    print(85 in log)

    Select one.

    • True
    • False
    • KeyError
    • None
  7. Predict, then check: what does this program print?

    words = ["red", "blue", "red", "red", "blue"]
    counts = {}
    for w in words:
        counts[w] = counts.get(w, 0) + 1
    print(counts)

    Select one.

    • {'red': 2, 'blue': 3}
    • {'red': 1, 'blue': 1}
    • {'red': 3, 'blue': 2}
    • {'blue': 2, 'red': 3}
  8. Predict, then check: what does this program print?

    d = {}
    d["zebra"] = 1
    d["apple"] = 2
    d["mango"] = 3
    print(list(d))

    Select one.

    • ['apple', 'mango', 'zebra']
    • ['mango', 'apple', 'zebra']
    • ['zebra', 'mango', 'apple']
    • ['zebra', 'apple', 'mango']
  9. Select every program that stops with an error when it runs. Predict first, then run each one to check.

    Select every option that applies.

    • spot = (3, 4)
      spot[0] = 9
    • shelf = {["atlas"]: 85}
    • log = {"atlas": 85}
      print(log.get("comics", 0))
    • print(len({1, 2, 2, 3}))
    • print(type({}))
  10. True or false: this program prints not logged yet, because the test title in log is False, so only the else branch runs.

    log = {"river book": 120, "atlas": 85}
    title = "comics"
    if title in log:
        print(log[title])
    else:
        print("not logged yet")

    True or false.

    • True
    • False

Built with The Course Maker · samples.thecoursemaker.com