OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.get_terminal_size() method in Python is used to query the size of a terminal. This method returns the size of a terminal as a pair columns and lines. Here, columns represents width of the terminal window in characters and lines represents height of the terminal window in characters.
Syntax: os.get_terminal_size(fd = STDOUT_FILENO)
fd (optional): A file descriptor. It specifies which file descriptor should be queried. The default value of fd parameter is STDOUT_FILENO or standard output.
Return Type: This method returns a object of class ‘os.terminal_size’ which holds columns and lines attributes.
Code: Use of os.get_terminal_size() method
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course