A brief introduction to functional programming in Python

a calculator and a scale ruler
a calculator and a scale ruler
Photo by Karolina Grabowska from Pexels

Python is a multi-paradigm programming language. It supports different programming paradigms like procedural programming, object-oriented programming and functional programming. In this article we will understand the basic concepts of functional programming.

What is functional programming?

Functional programming is a programming paradigm, a style to organize our code. Separation of data and functions is the main idea of functional programming. Where data is to be acted upon and functions will act or determine what to do.

In functional programming, we write the code in pure mathematical function style.

Working with CSV files in Python.

Image for post
Image for post
Image by author | csv Icon by Freepik from www.flaticon.com

We often exchange data through text files between our programs. Maybe we need to load data from a database. Maybe we need to generate a large amount of data in our program and save them. CSV is one of the most common and popular file format to exchange data between programs.

Python has built-in csv module to work with CSV files. This module provides us functions to work with CSV files easily.

What is a CSV File

The word CSV stands for “comma-separated values”. A CSV file is a simplified spreadsheet stored as plaintext. The structure of a CSV file is as straightforward as its…

How to use the built-in os module in Python and interact with the operating system.

Python os module
Python os module
Image by author

The os module in Python allows us to interact with the operating system. We can do operations like navigating the file system, creating or deleting files, finding file information, renaming files and many more using the os module. In this article I will talk about some important things we can do with the os module in Python.

The OS Module

The os module comes built in with Python. So we don’t need to install it. We can simply import it in our Python file to use it.

>>> import os

We can print all the properties and methods of os using dir().


A brief introduction to Dynamic Programming by solving the Fibonacci number sequence.

Notebook, calculator, pencil
Notebook, calculator, pencil
Photo by cottonbro from Pexels

Dynamic programming is a commonly studied concept in Computer Science. It is not an algorithm. Rather it is an algorithmic technique to solve optimization and counting problems. Dynamic programming was introduced by American mathematician Richard Bellman. The name “dynamic” has nothing to do with the actual process.

There is nothing dynamic in dynamic programming!

To get started with the concept of dynamic programming an ideal example can be solving the Fibonacci number sequence. As it is very easy to understand. …

Learn what is enumerate() and how to use it.

Image for post
Image for post
Photo by Negative Space from Pexels

When we are dealing with iterables, we may need to keep track of the count of iterations. Python has a built-in function called enumerate() to help us with that. The enumerate() function adds counter to an iterable object and returns it as an enumerate object. Lists, tuples, strings etc. are iterable objects in Python. You can read my article on iterables and iterators. But now let’s talk about enumerate().

Parameters and Syntax

The enumerate() method takes two parameters:

  • iterable — The iterable object. This will be converted into an enumerate object.
  • start — This is where enumerate() starts counting from. By default 0…

A comparison between Python iterables and iterators

Image for post
Image for post
Photo by Andrew Neel from Pexels

The understanding of iterables and iterators in Python is very important. But it can be a little bit tricky. In this article I will try to give a comprehensive explanation of iterables and iterators. We will understand what they are, how they work and how to use them properly.

An iterable is an object which we can iterate over and an iterator is an object which we use to iterate over an iterable!

Let’s break down this confusing definition one by one…

Iterable Is an Object That We Iterate Over

What does the phrase “iterate over” means? Simply it means looping over something. When we have a collection…

Understand generators in Python and learn how they make iterations more efficient

A laptop a glass a pencil a mouse
A laptop a glass a pencil a mouse
Photo by fauxels from Pexels

Python generators help us to create our own iterators. They help us to generate a sequence of values over time. If we have a large amount of values to generate, using generators is the way to go.

“Generator functions allow you to declare a function that behaves like an iterator, i.e. it can be used in a for loop “— Python Wiki

In simple words, a generator is a function that will return a iterator object. We can iterate over this object once at a time.

Using a Generator

Implementing an iterator from scratch requires a lot of work. We have to implement…

How to create virtual environments and requirements.txt for our Python project

Woman coding with two monitors and a laptop
Woman coding with two monitors and a laptop
Photo by cottonbro from Pexels

Virtual environment in Python is a very useful concept. It helps us to manage our project dependencies properly and efficiently. In this article we will see how to create a virtual environment for our Python projects. Also how to create a requirements.txt.

Why Should We Care About Virtual Environments?

Virtual environments helps us to separate dependencies between different projects. A Python project may have a bunch of dependencies installed. And most of the time they differ from other projects’ dependencies. We don’t want to mix them up. Also dependencies get updated all the time. A project made with a previous version of a dependency may not work…

Enhance the understanding of Decorators in Python and know why they are so powerful

Image for post
Image for post
Photo by Negative Space from Pexels

Decorators in Python allow us to add more functionalities in a function. It is called metaprogramming because one part of the program adds something to another part of the program at compile time. Decorators are used before a function with @ sign.

A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate. — Datacamp’s definition of a decorator.

Following is the basic structure to use a decorator:

def function_name():


Create a simple GUI application using Python & Tkinter that visualizes various sorting algorithms

A monitor and a lamp
A monitor and a lamp
Photo by MockupEditor.com from Pexels

In this article we will build a Sorting Algorithm Visualizer using Python and Tkinter. Tkinter is a standard GUI library for Python. We will use it to create the user interface of our project. We will visualize Bubble Sort and Merge Sort. But we can implement all the comparison based sorting algorithms in this project. Wikipedia page on comparison sort.

File Structure of the Project

We will structure our project files at the very beginning. First we will create a folder and name it Sorting_Visualizer. This will be our project directory. Inside this folder we will create another folder named algorithms. Then we will create…

Fahadul Shadhin

Undergraduate CS student | Passionate about programming and tech

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store