Sarika Singh has Published 72 Articles

How to eliminate repeated lines in a python function?

Sarika Singh

Sarika Singh

Updated on 09-Sep-2023 09:24:47

5K+ Views

In this article we will discuss how to delete multiple lines that are repeated in Python. If the file is small and only has a few lines, the process of removing repeated lines from it could be performed manually. However, when dealing with huge files, Python can assist. Using File ... Read More

How can we return a dictionary from a Python function?

Sarika Singh

Sarika Singh

Updated on 27-Aug-2023 14:36:49

28K+ Views

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 Python dictionary is a collection ... Read More

How to list all functions in a Python module?

Sarika Singh

Sarika Singh

Updated on 26-Aug-2023 08:19:02

32K+ Views

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

Python program to find all duplicate characters in a string

Sarika Singh

Sarika Singh

Updated on 26-Aug-2023 08:14:18

31K+ Views

This article teaches you how to write a python program to find all duplicate characters in a string. Characters that repeat themselves within a string are referred to as duplicate characters. When we refer to printing duplicate characters in a string, we mean that we shall print every character, including ... Read More

How to know/change current directory in Python shell?

Sarika Singh

Sarika Singh

Updated on 26-Aug-2023 08:05:42

36K+ Views

A portable method of interacting with the operating system is offered through the OS Python Module. The module, which is a part of the default Python library, contains tools for locating and modifying the working directory. The following contents are described in this article. How to obtain the current ... Read More

How to create a zip file using Python?

Sarika Singh

Sarika Singh

Updated on 25-Aug-2023 01:02:19

45K+ Views

ZIP is an archive file format used to for lossless data compression. One or more directories or files are used to create a ZIP file. ZIP supports multiple compression algorithms, DEFLATE being the most common. ZIP files have .zip as extension. In this article we are going to discuss how ... Read More

How to copy files from one folder to another using Python?

Sarika Singh

Sarika Singh

Updated on 24-Aug-2023 17:14:22

39K+ Views

A file is a collection of information or data that is stored on a computer. You are already familiar with several file types, such as your audio, video, and text files. Text files and binary files are the two categories into which we often split files. Simple text is contained ... Read More

How to print all the values of a dictionary in Python?

Sarika Singh

Sarika Singh

Updated on 23-Aug-2023 13:04:37

80K+ Views

Python has a built-in method called values() that returns a view object. The dictionary's values are listed in the view object. We can use the values() method in Python to retrieve all values from a dictionary. Python's built-in values() method returns a view object that represents a list of dictionaries ... Read More

How to print all the keys of a dictionary in Python

Sarika Singh

Sarika Singh

Updated on 23-Aug-2023 12:57:45

92K+ Views

An unordered collection of data values is what a Python dictionary is. A Python dictionary contains a key: value pair, in contrast to other data structures that only include one value per entry. This article explains about the various ways to print all the keys of a dictionary in Python. ... Read More

What does the if __name__ ==

Sarika Singh

Sarika Singh

Updated on 23-Aug-2023 12:53:52

82K+ Views

This article explains what the Python code expression if __name__ == '__main__' means. A Python programme uses the condition if __name__ == '__main__' to only run the code inside the if statement when the program is run directly by the Python interpreter. The code inside the if statement is not ... Read More

1 2 3 4 5 ... 8 Next
Advertisements