File Reading Code Blocks and Error Count Quiz
5 Questions
0 Views

File Reading Code Blocks and Error Count Quiz

Created by
@VigilantStream

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following code blocks will print all of the names in names.txt?

  • names = open("names.txt", "r") for line in names: print(names)
  • names = open("names.txt", "r") for line in names: print(names); names.close()
  • names = open("names.txt", "r") for line in names: print(line) (correct)
  • names = open("names.txt", "r") for line in names: print("line")
  • How many errors are in the code below. It should open the file in read-only mode, read each line and print each line and then close the file.

  • 3
  • 2
  • 1
  • 4 (correct)
  • What will be the output of the following Python code?

  • True (correct)
  • None
  • False
  • Error
  • Write the output of the First Print statement:

    <p>Hello</p> Signup and view all the answers

    Write the output of the second Print statement:

    <p>'to '</p> Signup and view all the answers

    More Like This

    Use Quizgecko on...
    Browser
    Browser