Category: Basic Python

  • How to save python objects using joblib

    Often times you would want to save python objects for later use. For example, a dataset you constructed which could be used for several projects, or a transformer object with specific parameters you want to apply for different data, or even a machine learning learning model you trained. This is how to do it. First,…

  • Python List

    Lists in python are collection of objects. They can include any python objects such as numerals, strings, other lists and dictionaries. The list is defined by square bracket as follows: Python The above example shows an empty list. Following is an example of a list with numbers: Python Lists can also contain strings. Python Single…

  • Loops in Python: For Loop

    Loops are used when one wants to repeat a set of statements several times (iterations). For example, when you want to apply a set of operations on elements of a list, by choosing one element at a time, you can use a python loop. There are two types of loops: For loop:  For loop is…

  • While loop

    Many a times we will encounter a situation where we have to iterate over a group of statements until a specific condition is met. The number iterations that the loop should run is not fixed or known. In such cases, while loop is used. Statements inside a while loop are executed iteratively until a given…

  • Python functions: args and kwargs

    Earlier we saw how to write functions in python and how to call them in our program. For those functions, the number of inputs or arguments were defined. They took fixed number of positional or keyword arguments or had a default value assigned to one or more of the arguments. But how to handle situations…

  • Functions in python

    Functions are sets of statements that perform a specific task. They can be called by their names, more than once in a program. Inputs can be given to functions based on which they will perform a task and can give back the result. Functions avoid same code to be written over and over again, thus,…

  • Python dictionary

    Dictionaries are collection of objects which can be indexed using their keys. A dictionary contains items, which are key:value pairs. For one key in a dictionary, there can be only one value. Multiple keys can have same values. A dictionary can be created using a curly bracket, {}, or using dict() function. Python Python If we have to create a…