Sarika Singh has Published 33 Answers

How can we return a tuple from a Python function?

Sarika Singh

Sarika Singh

Updated on 26-Sep-2022 12:51:22

Tuples allow for the storage of multiple items in a single variable. The tuple is one of Python's four built-in data structures for storing data collections. It is an established collection that is ordered cannot be changed. Any object, even a tuple, can be returned by a Python function. Create ... Read More

How can we return a list from a Python function?

Sarika Singh

Sarika Singh

Updated on 26-Sep-2022 12:47:34

An ordered sequence of elements that can be changed or modified is known as a list in the Python programming language. An item is any element or value contained within a list. Lists are defined by having values inside square brackets [], just as strings are defined by characters inside ... Read More

How can we return a dictionary from a Python function?

Sarika Singh

Sarika Singh

Updated on 26-Sep-2022 12:45:25

Any object, such as dictionary, can be the return value of a Python function. Create the dictionary object in the function body, assign it to any variable, and return the dictionary to the function's caller. Data values are stored as key:value pairs in dictionaries. A dictionary is a collection that ... Read More

How do we use equivalence (“equality”) operator in Python classes?

Sarika Singh

Sarika Singh

Updated on 23-Sep-2022 12:17:05

Using comparison operators, we may compare various data types in Python. When creating custom classes, we are unable to simply compare them using the comparison operators. This article will go over various approaches to verify equivalence ("equality") in Python classes. Equality of class objects The == operator makes it simple ... Read More

How to append elements in Python tuple?

Sarika Singh

Sarika Singh

Updated on 26-Aug-2022 15:33:51

Tuples in Python are immutable, meaning that once they are created, their contents cannot be changed. However, there are situations when we want to change the existing tuple, in which case we must make a new tuple using only the changed elements from the original tuple. Following is the example ... Read More

What is a metaclass in Python?

Sarika Singh

Sarika Singh

Updated on 18-Aug-2022 12:50:11

Metaprogramming in python is defined as the ability of a program to influence itself. It is achieved by using metaclass in python. Metaclasses in Python Metaclasses are an OOP concept present in all python code by default. Python provides the functionality to create custom metaclasses by using the keyword type. ... Read More

How to destroy an object in Python?

Sarika Singh

Sarika Singh

Updated on 18-Aug-2022 12:39:40

When an object is deleted or destroyed, a destructor is invoked. Before terminating an object, cleanup tasks like closing database connections or filehandles are completed using the destructor. The garbage collector in Python manages memory automatically. for instance, when an object is no longer relevant, it clears the memory. In ... Read More

Data Hiding in Python

Sarika Singh

Sarika Singh

Updated on 18-Aug-2022 12:28:53

Data hiding is also known as data encapsulation and it is the process of hiding the implementation of specific parts of the application from the user. Data hiding combines members of class thereby restricting direct access to the members of the class. Data hiding plays a major role in making ... Read More

How to create a tar file using Python?

Sarika Singh

Sarika Singh

Updated on 18-Aug-2022 12:09:00

Tape Archive Files is what the letter TAR in tar files stands for. Tar files are the archive files which allows you to store numerous files in a single file. Open-source software is distributed using tar files. Tar files typically end in.tar, but after they've been compressed using tools like ... Read More

How to print characters from a string starting from 3rd to 5th in Python?

Sarika Singh

Sarika Singh

Updated on 18-Aug-2022 11:50:52

Python uses arrays of bytes called strings to represent unicode characters. In Python, string indexing ranges from 0 to n-1, where n is the length of the string. In a string of size n, characters can therefore be retrieved from 0 to n-1. For instance, the index of the text ... Read More

Advertisements