Podcast
Questions and Answers
Which of the following code blocks will print all of the names in names.txt?
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.
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?
What will be the output of the following Python code?
- True (correct)
- None
- False
- Error
Write the output of the First Print statement:
Write the output of the First Print statement:
Write the output of the second Print statement:
Write the output of the second Print statement: