Question: Task 0 3 : Understanding the os Module ( 3 0 points ) Write a Python script that uses the os module to perform the

Task 03: Understanding the os Module (30 points)
Write a Python script that uses the os module to perform the following tasks:
Display the current working directory.
Create a new directory called "test_dir" in the current working directory.
Change the current working directory to "test_dir".
Verify the current working directory has been changed.
Create a new file named "test_file.txt" in "test_dir".
a. You must write the following contents to test_file.txt:
This is a test file.
Verify that "test_file.txt" was created by listing the contents of "test_dir".
Display the file size and the last modification time of "test_file.txt".
Change the name of "test_file.txt" to "new_test_file.txt".
Verify the name change by listing the contents of "test_dir" again.
Finally, remove "new_test_file.txt" and "test_dir", verifying each deletion by listing the
contents of the parent directory.
Here is a screenshot of the expected behavior. Replicate this functionality in your script,
including the formatting and outputs of all messages.Current working directory:/home/eric/lab h
Current working directory: /home/eric/lab_h/test_dir
Contents of the current directory:
['test_file.txt']
File size of 'test_file.txt': 20 bytes
Last modification time of 'test_file.txt': Sun Jun 2522:55:082023
Contents of the current directory after renaming the file:
['new test file.txt']
Contents of the parent directory after deletion:
['lab_h_task_03_sdevil.py', 'lab_h_task_02_sdevil.py', 'lab_h_task_01_module_sdevil.py',
 Task 03: Understanding the os Module (30 points) Write a Python

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!