Sathiya Sarathi Gunasekaran
Pythonist 🐍| Linux Geek who codes on WSL | Data & Cloud Fanatic | Blogging Advocate |
How to Concatenate String Variables in Bash
Bash utilities make so many tasks simple, but not all tasks have a straightforward command or operator. A very common and usual task in many scripting scenarios is concatenating string variables. Bash doesn't have a built-in function or command-line utility to concatenate two strings together. However, there are many ways...
How to Print Colored Text in Python
It's typical for CLI apps to return text in the same color of the terminal. There are always cases when we want to highlight output to the user, for example, a warning or error message. In those cases, a dash of color could make a difference. This article shows you...
How to Split a List into Even Chunks in Python
Splitting strings and lists are common programming activities in Python and other languages. Sometimes we have to split our data in peculiar ways, but more commonly - into even chunks. The language does not have a built-in function to do this and in this tutorial, we'll take a look at...
Python: How to Print without Newline or Space
The print() function in Python appends a newline to the output when displayed on the tty (teletypewriter A.K.A the terminal). When you don't want your message displayed with newlines or with spaces, how can you change the behavior of print()? This can easily be achieved by altering the...
Python: How to Remove a Key from a Dictionary
In this article, we'll take a look at how to remove keys from Python dictionaries. This can be done with the pop() function, the del keyword, and with dict comprehensions. Remove a Key Using pop(key,d) The pop(key, d) function removes a key from a dictionary and returns...
Covariance and Correlation in Python
Working with variables in data analysis always drives the question: How are the variables dependent, linked, and varying against each other? Covariance and Correlation measures aid in establishing this. Covariance brings about the variation across variables. We use covariance to measure how much two variables change with each other. Correlation...
Python: Get Size of Dictionary
In this article, we'll take a look at how to find the size of a dictionary in Python. Dictionary size can mean its length, or space it occupies in memory. To find the number of elements stored in a dictionary we can use the len() function. To find the size...
How to Use the crontab Command in Unix
When managing a computer, we may want to automate some tasks to run in certain periods or at the same time on each day/week/month. On a desktop, we may schedule update checks or virus scans. On a server, it's not uncommon for a myriad of checks and clean...
Using __slots__ to Store Object Data in Python
In Python, every object instance comes pre-built with standard functions and attributes. For example, Python uses a dictionary to store an object's instance attributes. This has many benefits, like allowing us to add new attributes at runtime. However, this convenience comes at a cost. Dictionaries can consume a fair chunk...