Definition:
It is a ready-to-use module for managing files, creating directories, deleting files and folders, and managing paths.
It gets system information from the operating system.
It can perform OS-related tasks.
It is a built-in module, so no need to install it.
It works on different operating systems, such as Windows, Linux, and Mac computers.
It can also run system commands and access environment variables.
Now you will clearly understand the code logic with the help of the flowchart.
OS Module Flowchart :
Start ↓ You write program and import os import os ↓ Python loads os module ↓ os module connects with Operating System (Windows/Linux/Mac) ↓ You ask system information or task Example: os.getcwd() ↓ os module finds current working directory (folder path) ↓ Result comes ↓ Print output Example: C:/Users/YourName ↓ End
Syntax:
import os
Example:
import os
print(os.getcwd())
Output:
Exercise
Use os module to print current working directory using Python.
