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

Week 3 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. The user types 25, and the program stores the typed value as a string. What does the last line print?

    typed = "25"
    print(typed * 2)

    Select one.

    • 50
    • 25
    • 2525
    • TypeError
  2. The program converts the typed value before adding. What does the last line print?

    typed = "25"
    age = int(typed)
    print(age + 1)

    Select one.

    • 26
    • 251
    • 2525
    • TypeError
  3. The reading log prints its status line. What does the last line print?

    pages_read = 45
    print(f"{pages_read} pages read so far")

    Select one.

    • {pages_read} pages read so far
    • 45 pages read so far
    • pages_read pages read so far
    • TypeError
  4. Count from 0, and remember a slice drops its stop. What does the last line print?

    book = "the river book"
    print(book[4:9])

    Select one.

    • river
    • iver
    • rive
    • river
  5. What does the last line print?

    book = "the river book"
    print(book[-1])

    Select one.

    • t
    • k
    • o
    • IndexError
  6. Predict, then check: what does this one-line program print?

    print("PYTHON"[1:4])

    Select one.

    • YTH
    • PYT
    • YTHO
    • PYTH
  7. The title has 14 characters. When this program runs, what happens?

    book = "the river book"
    print(book[14])

    Select one.

    • It prints k
    • It prints an empty line
    • It prints the river book
    • IndexError, with nothing printed
  8. Which of these lines print without raising an error? Select every line that does.

    book = "the river book"
    pages_read = 45

    Select every option that applies.

    • print(book[13])
    • print(book[4:99])
    • print(book[14])
    • print(pages_read + " pages read so far")
    • print(book[len(book)])
  9. A chatbot tells you that print("PYTHON"[1:4]) displays YTHO, because the slice runs from index 1 to index 4. What is the best next step?

    Select one.

    • Accept YTHO, since the chatbot named both indexes
    • Ask the chatbot again until it gives one reply twice
    • Switch to a chatbot that sounds more confident
    • Run the line in a Python runner and compare its output with the claim
  10. This program prints Now reading: the river book and then stops at line 3. Because a line printed before the error, the program was running when it stopped, so this is a runtime error, and the last line of its error message names TypeError.

    book = "the river book"
    print(f"Now reading: {book}")
    print(45 + " pages read so far")

    True or false.

    • True
    • False

Built with The Course Maker · samples.thecoursemaker.com