1. What is the default mode for opening a file in Python?
'r'
'w'
'a'
'x'
2. Which method is used to read the entire file in Python?
file_object.read()
file_object.readline()
file_object.readlines()
file_object.read([n])
3. How are data stored in text files?
As ASCII or Unicode characters
In its raw memory format
As binary data
As hexadecimal values
4. What does the file_object
Closes the file
Forces the buffer to write to the file
Reads a line from the file
Writes a string to the file
5. Which mode should be used to add data to the end of an existing file?
'r'
'w'
'a'
'x'
6. How do you open a file using a relative path?
Using the full path from the root
Using a path relative to the current directory
Using the double backslash
Using an absolute path
7. What is the purpose of the with statement in file handling?
To open a file
To automatically close the file after the block of code
To read data from the file
To write data to the file
8. Which module is used for binary file operations such as dump and load?
sys
os
pickle
csv
9. How can you get the current working directory in Python?
import sys; sys.getcwd()
import os; os.getcwd()
import os; os.pwd()
import sys; sys.pwd()
10. What does file_object
Writes the string str to the file
Reads the string str from the file
Appends the string str to the file
Deletes the string str from the file
11. What is the use of EOL characters in text files?
To store data in raw format
To mark the end of a line
To write data to the file
To read data from the file
12. Which method reads all lines of a file into a list?
file_object.read()
file_object.readline()
file_object.readlines()
file_object.read([n])
13. How are binary files different from text files?
They store data as ASCII characters
They store data in its raw memory format
They use EOL delimiters
They store data as Unicode characters
14. What does the file_object
Reads data from the file
Writes data to the file
Ensures data is saved and file resources are released
Appends data to the file
15. What is the syntax to open a file for reading in Python?
open(filename, 'r')
open(filename, 'w')
open(filename, 'a')
open(filename, 'x')
16. What does the pickle
Writes an object to a binary file
Reads an object from a binary file
Appends an object to a binary file
Deletes an object from a binary file
17. What is the purpose of the sys
Reads from the keyboard
Writes errors to the monitor
Writes to the monitor
Reads from a file
18. What is the syntax to write a list of strings to a file?
file_object.write(str)
file_object.writelines(list)
file_object.read()
file_object.readlines()
19. How do you handle file paths with backslashes in Python?
Using single backslash
Using triple backslash
Using double backslash
Using quadruple backslash
20. Which file mode is used to overwrite an existing file?
'r'
'w'
'a'
'x'
Username
00:05:00
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Enter your name to start the quiz
General Directions for the Quiz
Welcome to our quiz! Please read the following instructions carefully to ensure a smooth and fair experience for all participants:
Timing: The quiz will begin promptly at [start time] and will last for [duration]. A countdown timer will be visible on your screen.
Question Format: The quiz consists of multiple-choice questions. You will have four options to choose from for each question. Select the best possible answer.
Navigation: You can move between questions using the navigation buttons. Please ensure that you have answered all questions before submitting.
Submission: Once you have answered all questions, click the 'Finish Test' button. A confirmation popup will appear to confirm your submission. After confirming, you will not be able to change your answers.
Auto-Submit: If the timer runs out before you submit, the quiz will be automatically submitted, and your answers will be recorded.
Fair Play: Cheating or using any unfair means is strictly prohibited. Any suspicious activity will lead to disqualification.
Results: Your results will be displayed immediately after you submit the quiz.
We wish you the best of luck! Enjoy the quiz and do your best!