0% found this document useful (0 votes)
475 views

Congratulations! You Passed!: Chapter 7 Quiz

This document summarizes a quiz on Python data structures from an online Coursera course. The quiz contains 10 multiple choice questions covering topics like where files are stored, using file handles, opening files, reading files line by line, and handling errors from invalid file names. The student scored 9 out of 10 points on the quiz.

Uploaded by

DeezNuts
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
475 views

Congratulations! You Passed!: Chapter 7 Quiz

This document summarizes a quiz on Python data structures from an online Coursera course. The quiz contains 10 multiple choice questions covering topics like where files are stored, using file handles, opening files, reading files line by line, and handling errors from invalid file names. The student scored 9 out of 10 points on the quiz.

Uploaded by

DeezNuts
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

03/05/2019 Python Data Structures - Home | Coursera

Chapter 7 Quiz 9/10 points (90%)


Quiz, 10 questions

Congratulations! You passed! Next Item

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

9/10 points (90%)


6. questions
Quiz, 10
If we open a le as follows:

1 xfile = open('mbox.txt')

What statement would we use to read the le one line at a time?

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 fname = input('Enter the file name: ')


2 fhand = open(fname)

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

You might also like