0% found this document useful (0 votes)
286 views

Files Quiz - Data Science Masters - PW Skills

The document is a quiz on files and modules in Python. It contains 11 multiple choice questions testing concepts like opening and reading files, the logging module, debugging, importing and reloading modules. The participant answered all 11 questions correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
286 views

Files Quiz - Data Science Masters - PW Skills

The document is a quiz on files and modules in Python. It contains 11 multiple choice questions testing concepts like opening and reading files, the logging module, debugging, importing and reloading modules. The participant answered all 11 questions correctly.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

3/3/23, 4:06 AM Files quiz - Data Science masters | PW Skills

Files quiz 11 out of 11 correct

1. To open a file c:\scores.txt for reading, we use _____

infile = open(“c:\scores.txt”, “r”)

infile = open(“c:\\scores.txt”, “r”)

infile = open(file = “c:\scores.txt”, “r”)

infile = open(file = “c:\\scores.txt”, “r”)

Explanation: -Execute help(open) to get more details.

2. Which of the following statements are true?

When you open a file for reading, if the file does not exist, an error occurs

When you open a file for writing, if the file does not exist, a new file is created

When you open a file for writing, if the file exists, the existing file is overwritten with the new file

All of the mentioned

Explanation: The program will throw an error.

3. Which one of the following is not attributes of file?

closed

softspace

rename

mode

Explanation: rename is not the attribute of file rest all are files attributes. Attribute Description file.closed Returns
true if file is closed, false otherwise. file.mode Returns access mode with which file was opened. file.name
Returns name of the file. file.softspace Returns false if space explicitly required with print, true otherwise.

4. Which of these class contains the methods used to write in a file?

FileStream

FileInputStream

BUfferedOutputStream
https://learn.pwskills.com/quiz/-Files-quiz/63e7b4f1194b220eaee5abe5/course/Data-Science-masters/63a2eb428899436daf7eb489 1/3
3/3/23, 4:06 AM Files quiz - Data Science masters | PW Skills

FileBufferStream

Explanation: None.

5. Which of these methods are used to read in from file?

get()

read()

scan()

readFileInput()
 

Explanation: Each time read() is called, it reads a single byte from the file and returns the byte as an integer
value. read() returns -1 when the end of the file is encountered.

6. .the logging …….. In python.

function

module

variable

datatype

Explanation: The logging module in Python is a ready-to-use and powerful module that is designed to meet the
needs of beginners as well as enterprise teams. It is used by most of the third-party Python libraries, so you can
integrate your log messages with the ones from those libraries to produce a homogeneous log for your
application.

7. which one of the following is the lowest level of logging?


 

debug

warming

error

none of the above

Explanation: Debug is the lowest logging level, it's used to log some diagnostic information about the application.

8. Which of the following is not a logging function in Python?

logger

https://learn.pwskills.com/quiz/-Files-quiz/63e7b4f1194b220eaee5abe5/course/Data-Science-masters/63a2eb428899436daf7eb489 2/3
3/3/23, 4:06 AM Files quiz - Data Science masters | PW Skills

filter

critical

All the above

Explanation: "filter" is not a logging function in Python. It is actually a logging concept that allows you to control
the flow of log messages based on a set of rules. Filters can be used to exclude certain log messages, based on
their logging level, source, or any other criterion. Filters are specified using the addFilter method of a logger
object.

9. which of these is not involved in the process of debugging?

Fixing

Isolating

Identifying

Testing

Explanation: Testing is a different process and is different from debugging. Debugging involves identifying,
isolating and fixation of the problems or errors.

10. What is the purpose of of the import statement in python?

import the statement into a python program

import the function into a python program

import the module into a python program

 none of the above

Explanation: The import statement is used to import a module into a Python program, allowing you to use its
definitions and statements. By using the import statement, you can access all the variables, functions, and
classes defined in the imported module. You can then use them in your program as if they were defined locally.

11. How can you reload a module in Python?

 importlib.reload function.

 import reload

import logging

none of the above

Explanation: The importlib.reload function reloads a previously imported module, allowing you to pick up changes
that have been made to the module's code. This is useful in situations where you are developing a module and
need to test changes without restarting your program.

https://learn.pwskills.com/quiz/-Files-quiz/63e7b4f1194b220eaee5abe5/course/Data-Science-masters/63a2eb428899436daf7eb489 3/3

You might also like