Introduction In Python, this question can be tricky specially if you come from a C++ background where pass by value and pass by reference is well defined. So what does that mean in Python? This question is repeatedly asked and answered online. My take on that is through the following example… Define 4 data types
What is PIP PIP (stands for PIP Installs Packages) is a command line utility to manage (ex. install, uninstall, etc) Python packages. Depending on which Python version, you may or may not have it installed. Newer versions of Python already ship with PIP. If you do not have it installed, follow the steps below… Check
Introduction Welcome to a new code snippet post. Today, we are going to demonstrate how to read a text file line by line in Python. There are various ways to do that, however we are going to show the recommended method specially when dealing with large files. Let us get started… Using with statement A
Introduction In this post, I am going to provide a summary of using quotes in Python. It can be confusing to beginners but it should be easy to grasp by just looking at the following bullet points… Quotes in Python Strings literals in Python must be enclosed with single or double or triple quotes It
Introduction First, keep in mind that null is not part of the Python programming language syntax, though you can find it in other programming languages (ex. Java, JavaScript). In Python syntax, it is None. So what is None ? Do we really need it ? how is it used ? let us discuss that… None
Introduction Imagine that we have two or more dictionaries and we want to combine them into a single dictionary. How can we do that in Python? How do we handle collision when keys are the same? Let us explore that… Code snippets Consider the following example… We can merge the two dictionaries into a third
Introduction Given an input list of strings and a search keyword. We want to check if the search keyword is found in the input list (not necessarily an exact match). In other words, if the search keyword is a substring of at least one string in the input list then it is considered a match.
Problem Given a string of comma separated numbers, we want to convert that string to a Python list of integers Solution The idea here is to split the string into tokens then convert each token to an integer. We can do that in a couple of ways. Let us see how… Use a list comprehension
Introduction Quotes are special characters in Python used to represent string data type. If a single or double quote needs to be part of a string, we can do that in a couple of ways. Let us explore that… Code snippets Use single quotes if you want to add double quotes and visa versa. Here
Introduction Adding a signature to Gmail is a trivial task however many people still ask this question. Anyway, the following screenshots can help you find out how to do that easily… Click on settings icon Click on SettingsĀ in the popup menu In General, scroll down to Signature Click to enable signature then type your custom