Answered step by step
Verified Expert Solution
Link Copied!

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 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',
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

Explain the forces that influence how people handle conflict

Answered: 1 week ago