Python Exam 2 questions with correct
answers graded A+ (12)
If a file with the specified name already exists when the file is opened and the file is opened in 'w' mode,
then an alert will appear on the screen. - correct answer ✔✔False
When a piece of data is read from a file, it is copied from the file into the program - correct answer
✔✔false
closing a file disconnects the communication between the file and the program - correct answer ✔✔true
In python, there is nothing that can be donee if the program tries to access a file to read that does not
exist - correct answer ✔✔false
Python allows the programmer to work with text and number files - correct answer ✔✔false
The ZeroDivisionError exception is raised when the program attempts to perform the calculation x/y if y
= 0 - correct answer ✔✔true
An exception handler is a piece of code that is written using the try/except statement - correct answer
✔✔true
if the last line in a file is not terminated with \n, the deadline method will return the line without the \n -
correct answer ✔✔true
Strings can be written directly to a file with the WRITE method, but the numbers must be converted to
strings before they can be written. - correct answer ✔✔true
It is possible to create a WHILE loop that determines when the end of a file has been reached - correct
answer ✔✔true
, Which of the following is associated with a specific file and provides a way for the program to work with
that file - correct answer ✔✔the file object
What is the process of retrieving data from a file called - correct answer ✔✔reading data
which of the following describes what happens when a piece of data is written to a file - correct answer
✔✔the data is copied from a variable in RAM to a file
Which steep creates a connection between a file and a program - correct answer ✔✔open the file
How many types of files are there - correct answer ✔✔two
A(n) _______ access file is also known as a direct access file - correct answer ✔✔random
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 - correct answer ✔✔random
A single piece of data within a record is called a - correct answer ✔✔field
Which mode specifier will erase the contents of a file it if already exists and create the file if it does not
already exist - correct answer ✔✔'w'
Which mode specifier will open a file but not let you change the file or write to it - correct answer ✔✔'r'
Which method could be used to strip specific characters from the end of a string - correct answer
✔✔rstrip
Which method could be used to convert a numeric value to a string - correct answer ✔✔str
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Sakayobako30. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $14.99. You're not tied to anything after your purchase.