Quiz on File Handling in Python
Q.1. Which of the following true about FILE *fp
Q.2. Select the correct mode to open a file for appending as well as reading:
Q.3. Select the correct access mode to open a file only for exclusive creation
Q.4. Which of the following statements are true?
Q.5. What will be the output of the following Python statement?
f = None
for i in range (5):
with open("data.txt", "w") as f:
if i > 2:
break
print(f.closed)
Q.6. When reading a file using the file object, what method is best for reading the entire file into a
single string?
Q.7. Which method is used to read file line by line
Q.8. Given the file hfc.png, which of the following is the correct way to open the file for reading as a
buffered binary file? Select all that apply.
str = raw_input("Enter your input: ")
print ("Received input is : ", str)
Q.9. Appending data to a file places it at the start of the file.
Q.10. Which of the following mode will refer to binary data?
Q.11. Which method is used to sets the position of a file pointer
Q.12. Select the correct method to delete files in Python
Q.13.Select the correct method to write a list of lines to a file
Q.14. If the file is opened in write mode and already exists, it truncates the existing content and
places the filehandle at the beginning of the file.
Q.15. Which of the following are the modes of both writing and reading in binary format in file?
Instructions:-
- This Quiz is based on File Handling in Python
- Each correct answer will carry 2 points
- Once an option is selected you cannot select any other, So choose wisely
- Do not refresh the page as it will reset the quiz
- Once the time is up the quiz will automatically get submitted with no of Question responded
- Your total score alongwith your name will be shown after submission of the Quiz
- Wish you ALL THE BEST 👍👍
START
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP