Exam 8: Text Files

arrow
  • Select Tags
search iconSearch Question
  • Select Tags

An exception handler is the section of code that is executed when a particular exception type is caught.

(True/False)
4.8/5
(42)

When writing a line of text to a text file, the write method does not add a newline character to the output string.

(True/False)
4.7/5
(37)

To open a file for writing, the built-in _________ method is used, called with a required second parameter of ____.

(Short Answer)
4.7/5
(38)

Python contains a predefined set of exceptions called standard exceptions.

(True/False)
5.0/5
(32)

To open a file in Python for reading, the openRead function is called and passed the name of the file to open.

(True/False)
4.9/5
(42)

Provide Python code that opens a file named names.txt, in which each line of the file contains a friends name in the form firstname lastname, and displays each of the names on the screen, one per screen line.

(Short Answer)
4.8/5
(38)

A ___________________ is a file containing characters structured as lines of text, as well as nonprinting characters such as \n, the newline character.

(Short Answer)
5.0/5
(46)

It is more likely that an error may occur when opening a file for writing than when opening a file for reading.

(True/False)
4.8/5
(33)

Collectively, the operations performed on strings is called _______________________.

(Short Answer)
4.8/5
(35)

All raised exceptions should be able to be caught and handled to keep a program executing.

(True/False)
4.8/5
(31)

Strings are immutable in Python, and therefore cannot be altered.

(True/False)
4.8/5
(37)

Give Python code that display "Valid SSN" if the string assigned to variable SSN is a valid social security number, and displays "Invalid SSN" otherwise. A social security number is valid if it contains exactly nine digits, and no other characters.

(Essay)
4.7/5
(32)

When opening a file for reading, an error that may occur is ______________________________.

(Short Answer)
4.9/5
(37)

The section of code making a call to any function that raises an exception must be contained in a try suite (block).

(True/False)
4.9/5
(36)

Fundamental operations of files in include opening a file, _______ a file, __________ a file, and___________ a file.

(Short Answer)
4.9/5
(35)

Give Python code that for a first name and last name assigned to variable full_name with the first and last name separated by a single space (e.g., Alice Morgan), assigns the first name to variable first_name and the last name to variable last_name.

(Essay)
4.8/5
(36)

Text file is a file containing only printable characters.

(True/False)
4.7/5
(32)

A text file can be directly displayed on the screen.

(True/False)
4.8/5
(36)
Showing 41 - 58 of 58
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)