Account
Categories

Sys Module


Definition:

It is a module that works with Python and takes input from the command line.

It provides information about Python, such as its version and system details.

It controls the program if you want to stop it.

It also helps to pass values to the program.

It is a built-in module, so no need to install it.

It works on different operating systems, such as Windows, Linux, and Mac.

Now you will clearly understand the code logic with the help of the flowchart.

Sys Module Flowchart :

Start
↓
You write program and import sys
import sys
↓
Python loads sys module
↓
sys connects with system
↓
You ask: sys.version
↓
sys finds Python version
↓
Result comes 
↓
Print output (example: 3.12.0)
↓
End

Syntax:


import sys

Example:


import sys
print(sys.version)

Output:

Exercise

Use sys module to print Python version and system information.