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

Week 6 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: how many lines does this loop print?

    for letter in "river":
        print(letter)

    Select one.

    • 4
    • 5
    • 6
    • 1
  2. In this loop, which character does letter hold on the third pass?

    for letter in "river":
        print(letter)

    Select one.

    • i
    • r
    • e
    • v
  3. Predict, then check: what does this program print?

    for i in range(1, 5):
        print(i, end=" ")
    print()

    Select one.

    • 1 2 3 4
    • 1 2 3 4 5
    • 0 1 2 3
    • 0 1 2 3 4
  4. Predict, then check: what does this line print?

    print(list(range(0, 10, 3)))

    Select one.

    • [3, 6, 9]
    • [0, 3, 6, 9, 12]
    • [0, 3, 6, 9]
    • [0, 3, 6]
  5. Predict, then check: what does this line print?

    print(len(range(1, 10, 3)))

    Select one.

    • 9
    • 4
    • 10
    • 3
  6. The reading log starts at 45 pages and adds 30 pages a day. What is the last line this loop prints inside the loop?

    pages_read = 45
    for day in range(1, 8):
        pages_read = pages_read + 30
        print(day, pages_read)
    print(pages_read)

    Select one.

    • 8 285
    • 7 255
    • 6 225
    • 7 285
  7. This loop was written to add the numbers 1 through 5. What does it print?

    total = 0
    for n in range(1, 5):
        total += n
    print(total)

    Select one.

    • 15
    • 10
    • 4
    • 5
  8. Predict, then check: how many lines does this nested loop print?

    for i in range(2):
        for j in range(3):
            print(i, j)

    Select one.

    • 5
    • 3
    • 6
    • 2
  9. Which of these ranges produce exactly five numbers? Select every one that does.

    Select every option that applies.

    • range(5)
    • range(1, 5)
    • range(1, 6)
    • range(0, 10, 2)
    • range(0, 10, 3)
  10. True or false: in the pinned 3 by 3 table below, the inner loop runs once, and then the outer loop carries on to its next pass.

    for i in range(1, 4):
        for j in range(1, 4):
            print(i * j, end=" ")
        print()

    True or false.

    • True
    • False

Built with The Course Maker · samples.thecoursemaker.com