What is While Loop in Python

Python offers different flow control statements. The While loop is one of the flow control statements used in Python. In this tutorial, we will learn about while loops in Python with examples. The while loop The while loop is used for the repeated execution of code as long as the condition is true. Syntax of … Read more

Reverse List in Python

Sometimes we need to reverse the list in Python. In this tutorial, we will learn how to reverse a list in Python. 1. Using the list reverse method The list.reverse() method will reverse the elements of the list in place. Syntax of the list reverse method : Arguments: Reverse method does not take any parameters. … Read more

Python List Remove Duplicates

We may need to work with lists in Python, sometimes we need to remove duplicates from the list. In this article, we will discuss different list duplicate removal methods. Naive method First, we will look simple naive method to remove list duplicates. The basic logic is : Define a result list. Loop the input list. … Read more

10 Easter Eggs in Python

Easter eggs python

Have you heard about Python Easter eggs? In this article, we will discuss the 10 best Easter eggs in Python. 1.Simple Hello World This Easter egg will print a hello world message. Open the python terminal and try this code. Hello world can be printed using importing __phello__. 2. The Zen of Python As per … Read more

Python Single line If

If statements are important in any programming language. Python provides if statements, in this article we will discuss single line if statements. Let’s first understand the syntax of single line if statement in python. Example Output Singe line statements reduces number of lines but still maintains code quality, but don’t over use it; long and … Read more

Python docstrings, format and examples

In this tutorial, we will discuss python docstrings, and learn about docstring format with examples. What is docstring in Python? Docstring is a string literal appears after the definition of modules, functions or classes. In other words, it is a description of the function, class or module. Lets define a small function to calculate the … Read more

How To Use Lambda Function in Python

In this article, we will discuss lambda function definition and usages in Python. Lambda functions are also known as anonymous function or lambda expression. Lambda function definition A lambda function/expression is a notation used in the lambda calculus. A normal function is , where x is a variable but a lambda function as shown below … Read more

Class Variables and Instance Variables in Python

Class variables and instance variables are two important concepts related to classes in Python. In this article, we will discuss class variable and instance variables with examples. We can define empty class in Python as shown below Two types of variables associated with a Python class – instance variables and class variables. Instance variables Instance … Read more