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

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

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 (A)</p> Signup and view all the answers

Write the output of the second Print statement:

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

More Like This

Python File Handling Quiz
5 questions

Python File Handling Quiz

EvaluativeEnlightenment avatar
EvaluativeEnlightenment
Untitled
10 questions

Untitled

SmoothestChalcedony avatar
SmoothestChalcedony
Use Quizgecko on...
Browser
Browser