Sarika Singh has Published 71 Articles

What is an anonymous function in Python?

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 12:35:50

An anonymous function in Python is one that has no name when it is defined. In Python, the lambda keyword is used to define anonymous functions rather than the def keyword, which is used for normal functions. As a result, lambda functions are another name for anonymous functions. Syntax Following ... Read More

The return Statement in Python

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 12:09:39

The return statement in python is an extremely useful statement used to return the flow of program from the function to the function caller. The keyword return is used to write the return statement. Since everything in python is an object the return value can be any object such as ... Read More

Segregate 0’s and 1’s in an array list using Python?

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 12:06:22

The elements in the contiguous memory address are contained in the linear data structure known as an array. At these places, it primarily groups components of the same data type. Given an array of integers. The array is to be divided into two halves, 0s and 1s, according to ... Read More

How to list all functions in a Python module?

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 12:03:53

In this article we will discuss how to list all the functions in a Python module. A Python module contains multiple different functions that allow for extensive code reusability making complex code simple. It also enhances portability of python program by changing platform dependent code into platform independent APIs Python ... Read More

How variable scope works in Python function?

Sarika Singh

Sarika Singh

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

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

How to use *args and **kwargs in Python?

Sarika Singh

Sarika Singh

Updated on 19-Dec-2022 11:57:47

In this article we will discuss about *args and **kwargs properties and their usage in Python. To pass unspecified number of arguments to a function usually *args and **kwargs properties are used. The *args property is used to send a non-keyword variable length argument to a function call whereas ... 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

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

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

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

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

1 2 3 4 5 ... 8 Next
Advertisements