pencil-icon
Build your own quiz

Computers

University

Image

Python Files

285
plays

20 questions

Show Answers
See Preview
  • 1. Multiple Choice
    30 seconds
    1 pt

    Given the following file opened as song_file:


    I can't write one song that's not about you

    Can't drink without thinkin' about you

    Is it too late to tell you that

    Everything means nothing if I can't have you?


    What is the result of

    print(song_file.read(4)) ?

    I ca

    I can

    I c

    I can't write one song that's not about you

    Can't drink without thinkin' about you

    Is it too late to tell you that

    Everything means nothing if I can't have you?

  • 2. Multiple Choice
    30 seconds
    1 pt

    Given the following file opened as song_file:


    I can't write one song that's not about you

    Can't drink without thinkin' about you

    Is it too late to tell you that

    Everything means nothing if I can't have you?


    What is the result of

    print(text_file.readline(8)) ?

    I can't

    I can

    I can't write one song that's not about you

    Error

  • 3. Multiple Choice
    30 seconds
    1 pt

    Given a text file opened as file_in, which of the following will print the entire file? (Select ALL that apply.)

    print(file_in.read())

    print(file_in)

    lines = file_in.readlines()

    for line in lines:

    print(line)

    lines = file_in.readlines()

    for i in range(len(lines)):

    print(lines)

    for line in file_in:

    print(line)

  • Answer choices
    Tags
    Answer choices
    Tags

    Explore all questions with a free account

    Already have an account?