Congratulations! You Passed!: Chapter 7 Quiz
Congratulations! You Passed!: Chapter 7 Quiz
1/1
point
1.
Given the architecture and terminology we introduced in Chapter 1, where are les stored?
1/1
point
2.
What is stored in a " le handle" that is returned from a successful open() call?
1/1
point
3.
What do we use the second parameter of the open() call to indicate?
0/1
point
4.
What Python function would you use if you wanted to prompt the user for a le name to open?
1/1
point
5.
What is the purpose of the newline character in text les?
1/1
https://www.coursera.org/learn/python-data/exam/cSFUu/chapter-7-quiz 1/3
03/05/2019 Python Data Structures - Home | Coursera
Chapter 7 Quiz
point
1 xfile = open('mbox.txt')
1/1
point
7.
What is the purpose of the following Python code?
1 fhand = open('mbox.txt')
2 x = 0
3 for line in fhand:
4 x = x + 1
5 print(x)
1/1
point
8.
If you write a Python program to read a text le and you see extra blank lines in the output that are not
present in the le input as shown below, what Python string function will likely solve the problem?
1 From: [email protected]
2
3 From: [email protected]
4
5 From: [email protected]
6
7 From: [email protected]
8
9 ...
1/1
point
9.
https://www.coursera.org/learn/python-data/exam/cSFUu/chapter-7-quiz 2/3
03/05/2019 Python Data Structures - Home | Coursera
The following code sequence fails with a traceback when the user enters a le that does not exist. How
Chapter 7 Quiz
would you avoid the traceback and make it so you could print out your own error message when a bad le
9/10 points (90%)
name
Quiz, 10 was entered?
questions
1/1
point
10.
What does the following Python code do?
1 fhand = open('mbox-short.txt')
2 inp = fhand.read()
https://www.coursera.org/learn/python-data/exam/cSFUu/chapter-7-quiz 3/3