# Python

## What is Python?

If you are somehow connected to the world of programming, you might have heard about Python, which is one of the most popular programming languages in the world and is a choice of many people who are willing to learn programming, due to many reasons. If you are wondering about what is python, how can …

## Check if all the elements in the list are the same in Python

In this article, we are going to address a simple problem in python, in which, we are going to have a list, and in that, we are going to check if all the elements in the list are the same. There can be multiple methods to achieve this task, and we are going to discuss …

## Sum of all the digits in a given number Python program

In this article, we are going to understand and perform a simple and interesting python program, in which, we would have a number, and we need to calculate the sum of all the digits in the given number. Have a look at the below examples first, which give an idea about what are we required …

## How to create an array in Python

In python, if we want to store a collection of data, we can make use of the list. But the thing is that, in the list, we can have data of multiple data types. So, within a list, we can have integers, we can have strings, Booleans, another list, etc. But if you are familiar …

## How to get a random number in Python

In this article, we are going to understand how can we get a random number in Python. At times, we are in situations, when we need to have a random number in our Python programs. In such situations, we have the random module to our rescue. So here, we are going to understand how to …

## What is a deep copy in Python?

At times, in our python programs, especially in the case of mutable objects, we need to have some copy of objects, so that we can make changes to the copy, without affecting the original one. But when it comes to copy, you might have heard that we can have a shallow copy or a deep …

## What is name variable in Python?

In many different python programs, you might have seen the statement if __name__ == “__main__”. So here in this article, we are going to understand a special variable __name__. We would see some different examples, through which, we can understand what is __name__ variable, and this would also give us some idea about the instruction …

## What is an str method in Python?

In this article, we are going to understand the __str__ method in Python. This method can be said as the dunder str method, where the dunder means double underscores. These methods with double underscores are also called magic methods. So, the __str__ method returns the string representation of the object. Basically, the __str__ method is …

## How to create an empty set in Python

In this article, we are going to learn about how can we create an empty set in Python. Set is one of the built–in datatypes in Python, which can be used to store collection of data. The thing is that in the set, we cannot have duplicate elements. At times, we might need to create …

## Raw strings in Python

In this article, we are going to learn about raw strings in Python. Raw strings in Python are created by prefixing the string literal with ‘r’ or ‘R’. The useful thing about the raw string in Python is that the raw strings treat backslash as a literal character. This is useful at times, when we …