• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 4 out of 39 pages
Exam (elaborations)

Python Exam | Questions And Answers | Graded A+ | Updated

Document preview thumbnail
Preview 4 out of 39 pages

PYTHON EXAM | QUESTIONS AND ANSWERS | GRADED A+ | UPDATED

Content preview

1. When reading a file in Python, you must specify two items:
1. a file name and file properties
2. a file name and mode
3. a file name and size
4. a file name and data type

Title
When reading a file in Python, what information must be provided?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-01

2. Before accessing a file, the program must:
1. name the file
2. read the file
3. open the file
4. close the file

Title
Before accessing a file, what must be done to allow access to the file?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-02

3. After executing the following code snippet, what part is the file object?

infile = open("input.txt", "r")

1. infile
2. "input.txt"
3. "r"
4. input

Title
After executing the following code snippet, what part is the file object?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-03

4. In the following code snippet, what does the "r" represent?

,infile = open("input.txt", "r")

1. replace
2. recursive
3. random
4. read

Title
In the following code snippet, what does the "r" represent?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-04

5. In the following code snippet, what does the "w" represent?

outfile = open("output.txt", "w")

1. wrapper
2. write
3. width
4. web

Title
In the following code snippet, what does the "w" represent?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-05

6. In the following code snippet, what happens if the "output.txt" file does not
exist?

outfile = open("output.txt", "w")

1. An error message is displayed
2. An empty file is created
3. Nothing, this statement is ignored
4. A new file is created with at least one record

Title
In the following code snippet, what happens if the "output.txt" file does not exist?
type
mc
Section
7.1 Reading and Writing Text Files

, id
testbank-py-1-ch07-06

7. In the following code snippet, what happens if the "output.txt" file already
exists?

outfile = open("output.txt", "w")

1. Any new data is appended to the end
2. The existing file is emptied
3. Nothing, this statement is ignored
4. An error message is displayed

Title
In the following code snippet, what happens if the "output.txt" file already exists?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-07

8. What method ensures that the output has been written to the disk file?
1. commit()




2. write()




3. close()




4. complete()




Title
What method ensures that the output has been written to the disk file?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-08

9. Once a file has been opened, what method is used to read data from a file?
1. readline()
2. readfile()

, 3. readln()
4. open()

Title
Once a file has been opened, what method is used to read data from a file?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-2-ch07-09
from
testbank-py-1-ch07-09

10. The readline method reads text until an end of line symbol is encountered, how is
an end of line character represented?
1. \r




2. \t




3. ""




4. \n




Title
The readline method reads text until an end of line symbol is encountered, how is an
end of line character represented?
type
mc
Section
7.1 Reading and Writing Text Files
id
testbank-py-1-ch07-10

11. What is returned when the readline method reaches the end of the file?
1. \r




2. \t

Document information

Uploaded on
February 18, 2026
Number of pages
39
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
3
Followers
0
Items
885
Last sold
7 months ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions