Deck 6: Files and Exceptions

ملء الشاشة (f)
exit full mode
سؤال
What do you call the process of retrieving data from a file?

A) Retrieving data
B) Reading data
C) Input data
D) Get data
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Python allows the programmer to work with text and number files.
سؤال
Which method could be used to convert a numeric value to a string?

A) str
B) value
C) num
D) chr
سؤال
Which of these is associated with a specific file and provides a way for the program to work with that file?

A) Filename
B) Extension
C) File object
D) File variable
سؤال
What happens when a piece of data is written to a file?

A) Data is copied from a variable in RAM to a file.
B) Data is copied from a variable in the program to a file.
C) Data is copied from the program to a file.
D) Data is copied from a file object to a file.
سؤال
Closing a file disconnects the communication between the file and the program.
سؤال
The ZeroDivisionError exception is raised when the program attempts to perform a division by zero.
سؤال
What type of file access jumps directly to any piece of data in a file without reading the data that came before it?

A) Sequential
B) Random
C) Number
D) Text
سؤال
Assume 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')
سؤال
In Python, there is nothing that can be done if the program tries to access a file to read that does not exist.
سؤال
When a piece of data is read from a file, it is copied from the file into the program.
سؤال
When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string?

A) write
B) input
C) get
D) read
سؤال
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.
سؤال
How many types of files are there?

A) One
B) Two
C) Three
D) Four
سؤال
A(n) _____ access file is also known as a direct access file.

A) sequential
B) random
C) numbered
D) text
سؤال
Which method could be used to strip specific characters from the end of a string?

A) estrip
B) rstrip
C) strip
D) remove
سؤال
Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?

A) 'w'
B) 'r'
C) 'a'
D) 'e'
سؤال
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.
سؤال
Which mode specifier will open a file but will not let you change the file or write to it?

A) 'w'
B) 'r'
C) 'a'
D) 'e'
سؤال
Which method will return an empty string when it has attempted to read beyond the end of a file?

A) read
B) getline
C) input
D) readline
سؤال
A(n) _______________ file contains data that has not been converted to text.
سؤال
The term _______________ file is used to describe a file from which the program gets data.
سؤال
The term _______________ file is used to describe a file to which data is written.
سؤال
An exception handler is a piece of code that is written using the try/except statement.
سؤال
Programmers usually refer to the process of _______________ data in a file as "writing data to" the file.
سؤال
Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.
سؤال
A filename _______________ is a short sequence of characters that appear at the end of a filename preceded by a period.
سؤال
It is possible to create a while loop that determines when the end of a file has been reached.
سؤال
When a program needs to save data for later use, it writes the data in a(n) _______________.
سؤال
A(n) _______________ file contains data that has been encoded as text, using a scheme such as ASCII.
سؤال
A(n) _______________ access file retrieves data from the beginning of the file to the end of the file.
سؤال
A(n) _______________ gives information regarding the line number(s) that caused an exception.
سؤال
A(n) _______________ includes one or more statements that can potentially raise an exception.
سؤال
If the last line in a file is not terminated with a \n, the readline method will return the line without a \n.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/34
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 6: Files and Exceptions
1
What do you call the process of retrieving data from a file?

A) Retrieving data
B) Reading data
C) Input data
D) Get data
B
2
Python allows the programmer to work with text and number files.
False
3
Which method could be used to convert a numeric value to a string?

A) str
B) value
C) num
D) chr
A
4
Which of these is associated with a specific file and provides a way for the program to work with that file?

A) Filename
B) Extension
C) File object
D) File variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
5
What happens when a piece of data is written to a file?

A) Data is copied from a variable in RAM to a file.
B) Data is copied from a variable in the program to a file.
C) Data is copied from the program to a file.
D) Data is copied from a file object to a file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
6
Closing a file disconnects the communication between the file and the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
7
The ZeroDivisionError exception is raised when the program attempts to perform a division by zero.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
8
What type of file access jumps directly to any piece of data in a file without reading the data that came before it?

A) Sequential
B) Random
C) Number
D) Text
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
9
Assume 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')
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
10
In Python, there is nothing that can be done if the program tries to access a file to read that does not exist.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
11
When a piece of data is read from a file, it is copied from the file into the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
12
When a file has been opened using the 'r' mode specifier, which method will return the file's contents as a string?

A) write
B) input
C) get
D) read
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
13
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
14
How many types of files are there?

A) One
B) Two
C) Three
D) Four
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
15
A(n) _____ access file is also known as a direct access file.

A) sequential
B) random
C) numbered
D) text
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which method could be used to strip specific characters from the end of a string?

A) estrip
B) rstrip
C) strip
D) remove
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which mode specifier will erase the contents of a file if it already exists and create it if it does not exist?

A) 'w'
B) 'r'
C) 'a'
D) 'e'
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
18
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
19
Which mode specifier will open a file but will not let you change the file or write to it?

A) 'w'
B) 'r'
C) 'a'
D) 'e'
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
20
Which method will return an empty string when it has attempted to read beyond the end of a file?

A) read
B) getline
C) input
D) readline
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
21
A(n) _______________ file contains data that has not been converted to text.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
22
The term _______________ file is used to describe a file from which the program gets data.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
23
The term _______________ file is used to describe a file to which data is written.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
24
An exception handler is a piece of code that is written using the try/except statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
25
Programmers usually refer to the process of _______________ data in a file as "writing data to" the file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
26
Strings can be written directly to a file with the write method, but numbers must be converted to strings before they can be written.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
27
A filename _______________ is a short sequence of characters that appear at the end of a filename preceded by a period.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
28
It is possible to create a while loop that determines when the end of a file has been reached.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
29
When a program needs to save data for later use, it writes the data in a(n) _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
30
A(n) _______________ file contains data that has been encoded as text, using a scheme such as ASCII.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
31
A(n) _______________ access file retrieves data from the beginning of the file to the end of the file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
32
A(n) _______________ gives information regarding the line number(s) that caused an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
33
A(n) _______________ includes one or more statements that can potentially raise an exception.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
34
If the last line in a file is not terminated with a \n, the readline method will return the line without a \n.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 34 في هذه المجموعة.