My Report

Python File Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. To open a file c:\scores.txt for appending data, we use ____________

2. To read the next line of the file from a file object infile, we use ____________

3. To read two characters from a file object infile, we use ____________

4. To open a file c:\scores.txt for writing, we use ____________

5. To read the entire remaining contents of the file as a string from a file object infile, we use ____________

6. What will be the output of the following Python code?

f = None
for i in range (5):
    with open("data.txt", "w") as f:
        if i > 2:
            break
print(f.closed)

7. Which of the following statements are true?

8. To read the remaining lines of the file from a file object infile, we use ____________

9. The readlines() method returns ____________

10. To open a file c:\scores.txt for reading, we use _____________


 

Start practicing “1000 MCQs on Python”, and once you are ready, you can take tests on all topics by attempting our “Python Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.