Quiz 8 – File I/O
Graded Quiz • 30 min Quiz6 Questions Week 4
Re⥃askly Logo

Quiz 8 – File I/O

Graded Quiz • 30 min Quiz6 Questions Week 4
Practice More Quizzes:
Quiz
Quiz
09 Questions Week 2
Quiz
5 Questions Week 2
Quiz
5 Questions Week 3
Quiz
05 Questions Week 3
Quiz
07 Questions Week 4
Quiz
6 Questions Week 4

Q:

What does the following code do? f = open(“test.txt”)

Q:

What does the following code do? f = open(“test.txt”, “r+”)

Q:

What will happen if you run the following code, but “test.txt” does not exist? f = open(“test.txt”, “a”) </pre.

Q:

Which of the following commands can be used to read all of the content in a file object f as a string?

Q:

What is the result of the following code? lst = [] with open(“text.txt”, “r”) as f: lines = f.readlines() for i in range(2): lst.append(lines[i].rstrip()) print(lst) If we have a file “text.txt” with the following content?

Q:

What is the result of the following code? with open(“text.txt”, “w”) as f_write: f_write.write(“That is the wisdom of life.”) with open(“text.txt”, “r”) as f_read: line = f_read.readline() print(line) If we have a file “text.txt” with following content?

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Find Questions in This Page: "CTRL+F"