Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 0 3 : Understanding the os Module ( 3 0 points ) Write a Python script that uses the os module to perform the
Task : Understanding the os Module 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 "testdir" in the current working directory.
Change the current working directory to "testdir".
Verify the current working directory has been changed.
Create a new file named "testfile.txt in "testdir".
a You must write the following contents to testfile.txt:
This is a test file.
Verify that "testfile.txt was created by listing the contents of "testdir".
Display the file size and the last modification time of "testfile.txt
Change the name of "testfile.txt to "newtestfile.txt
Verify the name change by listing the contents of "testdir" again.
Finally, remove "newtestfile.txt and "testdir", 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:homeericlab h
Current working directory: homeericlabhtestdir
Contents of the current directory:
testfile.txt
File size of 'testfile.txt: bytes
Last modification time of 'testfile.txt: Sun Jun ::
Contents of the current directory after renaming the file:
new test file.txt
Contents of the parent directory after deletion:
labhtasksdevil.py 'labhtasksdevil.py 'labhtaskmodulesdevil.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started