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

Week 9 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 the last line of this program print?

    daily = [12, 40, 25, 0, 33, 17, 27]
    print(daily[0])
    print(daily[1:3])

    Select one.

    • [40, 25, 0]
    • [40, 25]
    • [12, 40]
    • [12, 40, 25]
  2. Predict, then check: what does this program print?

    a = [1, 2, 3]
    b = a
    b.append(4)
    print(a)

    Select one.

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

    nums = [3, 1, 2]
    nums = nums.sort()
    print(nums)

    Select one.

    • None
    • [1, 2, 3]
    • [3, 1, 2]
    • [3, 2, 1]
  4. A practice log removes every 0 while the loop walks the same list. Predict, then check: what does it print?

    minutes = [0, 0, 90, 0, 85]
    for m in minutes:
        if m == 0:
            minutes.remove(0)
    print(minutes)

    Select one.

    • [90, 85]
    • [0, 90, 85]
    • [90, 0, 0, 85]
    • [90, 0, 85]
  5. Predict, then check: what does the last line of this program print?

    tasks = ["email", "lunch"]
    tasks.append("gym")
    tasks.insert(0, "coffee")
    done = tasks.pop(0)
    print(done, tasks)

    Select one.

    • coffee ['coffee', 'email', 'lunch', 'gym']
    • coffee ['email', 'lunch', 'gym']
    • None ['email', 'lunch', 'gym']
    • email ['coffee', 'lunch', 'gym']
  6. Predict, then check: what does the last line of this program print?

    a = [1, 2]
    a.append([3, 4])
    print(a)
    b = [1, 2]
    b.extend([3, 4])
    print(b)
    print(len(a), len(b))

    Select one.

    • 4 4
    • 3 3
    • 3 4
    • 4 3
  7. True or false: this program prints True on both lines, because a and b hold equal items.

    a = [1, 2]
    b = [1, 2]
    print(a == b)
    print(a is b)

    True or false.

    • True
    • False
  8. Which of these hand back None after they change a list in place? Select every one that does.

    Select every option that applies.

    • .append(x)
    • .pop()
    • .sort()
    • sorted(nums)
    • .remove(x)
  9. The reading log walks its week of daily pages. Predict, then check: what does the first print line show?

    daily = [12, 40, 25, 0, 33, 17, 27]
    total = 0
    for pages in daily:
        total = total + pages
    print(total)
    print(total / len(daily))

    Select one.

    • 127
    • 22
    • 7
    • 154
  10. In the same reading-log program, what does the second print line show?

    daily = [12, 40, 25, 0, 33, 17, 27]
    total = 0
    for pages in daily:
        total = total + pages
    print(total)
    print(total / len(daily))

    Select one.

    • 22
    • 22.0
    • 154
    • 7

Built with The Course Maker · samples.thecoursemaker.com