Python lets you create a function on the go, but without really assigning a name to the function. These “anonymous” functions are called “Lambda Functions”. One typically writes a lambda function on the fly, when one wants to write a function for one-time use. Lambda Functions come handy in a variety of situations and are […]
Python Tips
12 Basic Commands with NumPy Array
NumPy (pronounced as Num-pee or Num-pai) is one of the important python packages (other being SciPy) for scientific computing. NumPy offers fast and flexible data structures for multi-dimensional arrays and matrices with numerous mathematical functions/operations associated with it. Core data structure in NumPy is “ndarray”, short for n-dimesional array for storing numeric values. Let us […]
How to read entire text file in Python?
Often one might need to read the entire content of a text file (or flat file) at once in python. In this post, we showed an example of reading the whole file and reading a text file line by line. Here is another way to import the entire content of a text file.
5 Examples of Using List Comprehensions in Python
List Comprehensions in Python are awesome. List Comprehensions lets your create lists without actually writing a for loop. A while back wrote a post on some examples of using List Comprehensions in Python. Here are 5 more examples of List Comprehensions, that will come in extremely handy whenever you deal with lists in Python. 1. […]
Three Ways to Merge (or flatten) Lists in Python
Often you may have to flatten a list of lists or merge multiple lists into a single list in python. Obviously there are multiple ways to go about it. Here are three ways to flatten or merge lists in to a list. Merge with “+” Operator” If you have three separate lists like [1, 2, […]