Python sys Module

Python sys module deals with the system and environment-specific variables and parameters. We can use it to read the PATH variable and the list of command-line parameters passed to the Python script. Import sys Module in Python Before using any module, it needs to be imported. Syntax: import module_name Example: import sys Python sys.modules This …

Python sys Module Read More »

The pickle Module in Python

We often come across a situation where we would need to store or transfer objects. The pickle module in Python is one such library that serves the purpose of storing Python objects as a serialized byte sequence into files for retrieval at a later time. Let us look into what it exactly does in this …

The pickle Module in Python Read More »

@staticmethod in Python

The @staticmethod decorator Python @staticmethod decorator is used to label a class method as a static method, which means that it can be called without instantiating the class first. It simply defines a normal function that is logically contained in the class for readability purposes. Here, we do not need to pass the class instance …

@staticmethod in Python Read More »

Python AND Operator

Operators are basically used to perform operations on the data to be manipulated. There are various kinds of operators i.e. Logical Operators, Bitwise Operators, Arithmetic Operators, etc. There are two kinds of AND Operators in Python: Logical AND Operator Bitwise AND Operator Logical AND Operator Logical AND operator work with boolean values and results into …

Python AND Operator Read More »

Introduction to Python Modules

Modules are the pre-defined files that contain the python codes which depict the basic functionalities of class, methods, variables, etc. It consists of different functions, classes in a group of files inside a directory. Modules can also be termed as Libraries. These are basically the pre-defined methods that can be used to make the code …

Introduction to Python Modules Read More »

*args and **kwargs in Python

Python provides some handy ways through which we could make a function take a variable number of arguments. *args and **kwargs do just that. *args -> Represents a List / Tuple of positional arguments to be passed to any function **kwargs -> Represents a Dictionary of keyword arguments to be passed to any function Purpose …

*args and **kwargs in Python Read More »

String Comparison in Python

The following are the ways to compare two string in Python: By using == (equal to) operator By using != (not equal to) operator By using sorted() method By using is operator By using Comparison operators 1. Comparing two strings using == (equal to) operator Output: Enter the first String: AA Enter the second String: …

String Comparison in Python Read More »

Python Reverse String

Strings are basically sequence of characters. Python doesn’t support in-built string functions such as reverse() to reverse a string. The following are the ways to reverse a string in Python: By using a for loop By using a while loop By using a Slicing By using join() method By using Recursion By using List reverse() …

Python Reverse String Read More »