• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 4 fuera de 39 páginas
Examen

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

Document preview thumbnail
Vista previa 4 fuera de 39 páginas

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

Vista previa del contenido

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

Información del documento

Subido en
18 de febrero de 2026
Número de páginas
39
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$16.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
3
Seguidores
0
Artículos
885
Última venta
8 meses hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes