Filters
Question type

Study Flashcards

What is the process of retrieving data from a file called?


A) retrieving data
B) reading data
C) reading input
D) getting data

Correct Answer

verifed

verified

A(n)___________ file contains data that has been encoded as text,using a scheme such as ASCII.

Correct Answer

verifed

verified

text

It is possible to create a while loop that determines when the end of a file has been reached.

Correct Answer

verifed

verified

In Python,there is nothing that can be done if the program tries to access a file to read that does not exist.

Correct Answer

verifed

verified

Given that the customer file references a file object,and the file was opened using the 'w' mode specifier,how would you write the string 'Mary Smith' to the file?


A) customer file.write('Mary Smith')
B) customer.write('w', 'Mary Smith')
C) customer.input('Mary Smith')
D) customer.write('Mary Smith')

Correct Answer

verifed

verified

Python allows the programmer to work with text and number files.

Correct Answer

verifed

verified

False

If data is retrieved from a file by a program,this is known by the term __________ file.

Correct Answer

verifed

verified

input

Which of the following is the correct way to open a file named users.txt in 'r' mode?


A) infile = open('r', users.txt)
B) infile = read('users.txt', 'r')
C) infile = open('users.txt', 'r')
D) infile = readlines('users.txt', r)

Correct Answer

verifed

verified

Which mode specifier will erase the contents of a file if it already exists and create the file if it does not already exist?


A) 'w'
B) 'r'
C) 'a'
D) 'e'

Correct Answer

verifed

verified

Which statement can be used to handle some of the runtime errors in a program?


A) an exception statement
B) a try statement
C) a try/except statement
D) an exception handler statement

Correct Answer

verifed

verified

A(n)___________ block includes one or more statements that can potentially raise an exception.

Correct Answer

verifed

verified

What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts? What will be the output after the following code is executed and the user enters 75 and -5 at the first two prompts?   A)  ERROR: cannot have 0 items B)  ERROR: cannot have 0 items ERROR: number of items can't be negative C)  ERROR: number of items can't be negative D)  Nothing; there is no print statement to display average. The ValueError will not catch the error.


A) ERROR: cannot have 0 items
B) ERROR: cannot have 0 items
ERROR: number of items can't be negative
C) ERROR: number of items can't be negative
D) Nothing; there is no print statement to display average. The ValueError will not catch the error.

Correct Answer

verifed

verified

A(n)__________ gives information about the line number(s)that caused an exception.

Correct Answer

verifed

verified

Which of the following is the correct way to open a file named users.txt to write to it?


A) outfile = open('w', users.txt)
B) outfile = write('users.txt', 'w')
C) outfile = open('users.txt', 'w')
D) outfile = open('users.txt')

Correct Answer

verifed

verified

A filename __________ is a short sequence of characters that appear at the end of a filename,preceded by a period.

Correct Answer

verifed

verified

If the last line in a file is not terminated with \n,the readline method will return the line without \n.

Correct Answer

verifed

verified

Which method could be used to strip specific characters from the end of a string?


A) estrip
B) rstrip
C) strip
D) remove

Correct Answer

verifed

verified

Which type of file access jumps directly to a piece of data in the file without having to read all the data that comes before it?


A) sequential
B) random
C) numbered
D) text

Correct Answer

verifed

verified

When a piece of data is read from a file,it is copied from the file into the program.

Correct Answer

verifed

verified

Which step creates a connection between a file and a program?


A) open the file
B) read the file
C) process the file
D) close the file

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer