Sarika Singh has Published 192 Articles

How variable scope works in Python function?

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 12:01:30

270 Views

In this article we will discuss about how a variable scope works in Python function. The scope of a name is the area of a program in which you can clearly access a name, such as variables. Hence, a variable scope is the region in which we can access ... Read More

What is the meaning of single underscore prefix with Python variables?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:33:34

5K+ Views

Python variable name may begin with a single underscore. It functions as a convention to indicate that the variable name is now a private variable. It should be viewed as an implementation detail that could change at any time. Programmers can assume that variables marked with a single underscore are ... Read More

What does double underscore prefix do in Python variables?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:30:59

5K+ Views

When a double underscore is added as prefix to python variables the name mangling process is applied to a specific identifier(__var) In order to avoid naming conflicts with the subclasses, name mangling includes rewriting the attribute name. Example Following is the program to explain the double underscore in Python − ... Read More

Python Program to print unique values from a list

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:24:42

3K+ Views

List is a built-in data structure in python which functions like a dynamically sized array. Lists are created by putting elements in square brackets ‘[element 1, element 2, ….]’. Elements present in list are indexed and the indexing starts from [0]. List has the following properties − List is ... Read More

How to dynamically load a Python class?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:22:09

5K+ Views

A class is a group of items. It is a logical entity with a few unique attributes and methods. For instance, if you have a class for Cricket, it should have an attribute and method like players, tournaments, toss, runs, wickets, matches, etc. Use the keyword ‘class’ to create a ... Read More

How do we handle circular dependency between Python classes?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:18:22

5K+ Views

In this article we are going to discuss how to handle the circular dependency between Python classes. First of all, let us understand what is circular dependency. When two or more modules depend on one another, this is known as a circular dependency. This is because each module is defined ... Read More

How do I make a subclass from a super class in Python?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:14:02

4K+ Views

In this article we are going to discuss how to create subclass from a super class in Python. Before proceeding further let us understand what is a class and a super class. A class is a user-defined template or prototype from which objects are made. Classes offer a way to ... Read More

Explain Python class method chaining

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:10:56

15K+ Views

In OOP languages methods are a piece of code that can perform a specific task to produce a desired output. Methods are created inside classes and are invoked or called by objects of the class. Methods are extremely useful in programming as they provide modularity to code by breaking a ... Read More

Python program to split and join a string?

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:08:52

10K+ Views

We'll learn how to split and join a string in Python in this article. Python defines strings as a collection of characters enclosed in one, two, or three quotations. When a string is split, it is divided into smaller strings using a specific delimiter. A set of one or more ... Read More

Python Program to replace a word with asterisks in a sentence

Sarika Singh

Sarika Singh

Updated on 23-Nov-2022 08:07:48

3K+ Views

The use of the symbol * (asterisks) in writing or printing as a reference mark, a sign that some letters or words have been omitted, a way to indicate a possible but unproven linguistic form, or for other arbitrary purposes. In this article we will discuss different ways to replace ... Read More

Advertisements