Getting Started with Sort in Python: Sorting Lists in-place

Let us starting simple and start with easy sort. Python has two sort functions; one function that sorts a list in-place and the other sort function “sorted” that creates a new sorted list. In this post, we will see examples of “in-place” sorting. Python’s in-place sorting As the name suggests the in-place sorting replaces the […]

Mastering Lists in Python Using List Comprehensions

Ever faced the problem of creating a unique lists in Python? or Accessing only specific elements of lists in Python? Python’s “List Comprehensions” offers you the immense power to create and use lists. Here is a brief introduction to understand and getting started on using List Comprehensions in Python. Python’s List Comprehensions Example 1 The […]

Getting Started With Map, Filter, and Reduce in Python

Python has a couple of nice built-in function in the flavor of functional programming paradigm. These built-in functions like map, filter, and apply combine very well with lambda functions. Map, filer, and reduce help you create, work with and tame lists in Python. For example sure, at some point you will have to deal with […]

Running Python Command Line and Getting Arguments

When you are writing a python program and want to run the Python script as a command from the terminal, you may want to get the arguments to the python program from command line. For example, you might want to execute the Python script and use its arguments. Python input1 input2 Python’s sys module’s […]

Getting Started with Lambda Functions in Python

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, if one wants to write a function for one-time use. Lambda Functions come handy in a variety of situations and are […]

Free Python Books Online

Beginning to learn Python and in need of free Python materials? There are a number of wonderful Python resources online for free. Here is a list of free python eBooks that can be either read online or downloaded it as pdf files and read at your leisure. Although the Python Documentation is a great resource, […]

Getting Started With Python Dictionaries: Python Tips

Dictionary in Python is a data structure that lets users store and retrieve things in python. As the name “dictionary” suggests, it has “key” and “value”. Needless to say each key has to be unique, but you can have duplicates in values. How to Create a Dictionary in Python? An easy way to create dictionary […]

Three Ways to Read A Text File Line by Line in Python

Opening a file and reading the content of a file is pretty easy in Python. One easy way to read a text file and parse each line is to use the python statement “readlines” on a file object. Python’s “readlines” reads everything in the text file and has them in a list of lines. Here […]