💡 For the best experience, set your browser zoom level to 75%

    ‎75%‎ للحصول على أفضل تجربة، اضبط مستوى تكبير المتصفح على 💡

Skip to main content
Completion requirements

Lesson 14 - Assignment

Write a Python script that:

1.    Creates a text file called data.txt and writes three lines of text into it.

2.    Reopens the same file and reads:

o   The entire content using read()

o   The first line using readline()

3.    Closes the file.

4.    Uses the os.path.exists() method to check if data.txt exists.

o   If it exists, delete it using os.remove()

o   Otherwise, print "File does not exist."

5.    Creates a folder called test_folder and then removes it using os.rmdir() (after checking it exists).