Found 27104 Articles for Server Side Programming

Group list by first character of string using Python

Rohan Singh
Updated on 17-Jul-2023 18:27:33

411 Views

In Python, we can group lists by the first character of a string using various methods like using a Dictionary, using itertools.groupby, using a Defaultdict, etc. This can be useful in various scenarios, such as organizing names or categorizing data. In this article, we will explore different approaches to group lists by the first character of a string using Python. Method 1:Using a Dictionary In this method the keys of the dictionary will represent the first characters, and the corresponding values will be lists containing all the strings starting with that character. Syntax list_name.append(element) Here, the append() function is ... Read More

Group Keys to Values List Using Python

Rohan Singh
Updated on 17-Jul-2023 18:25:54

2K+ Views

Grouping keys to values is the process of categorizing data based on specific attributes or criteria. For example, imagine you have a dataset of students, and you want to group them by their grades. This grouping allows us to easily analyze and perform computations on each category separately. In Python, we can Group keys to values list in various ways like using dictionaries, defaultdict, and itertools.groupby. In this article, we will understand how we can Group keys to a Values list using these methods. Method 1:Using Dictionaries We can easily group keys to values using dictionaries in Python. Let's consider ... Read More

Group Elements in Matrix using Python

Rohan Singh
Updated on 17-Jul-2023 17:58:37

177 Views

Matrices are widely used in various fields, including mathematics, physics, and computer science. In some situations, we need to group elements of the matrix based on certain criteria. We can group elements of the matrix by row, column, values, condition, etc. In this article, we will understand how we can group elements of the matrix using Python. Creating a Matrix Before diving into the grouping methods, we can start by creating a matrix in Python. We can use the NumPy library to work with matrices efficiently. Here's how we can create a matrix using NumPy:Example The below code creates a ... Read More

Globals() Function in Python

Rohan Singh
Updated on 17-Jul-2023 18:16:59

129 Views

In Python, every program has a symbol table that contains the information about its names (variables, functions, and classes) defined in the program. The global() function allows us to access and manipulate the global symbol table, providing valuable information about the current global variables in a program. In this article, we will understand how these globals() function works and what we can do with this function in Python. Overview of globals() function In Python, each program has a symbol table that contains information about the names (variables, functions, classes, etc.) defined in the program. The symbol table is represented by ... Read More

Get the summation of numbers in a string list using Python

Rohan Singh
Updated on 17-Jul-2023 18:20:00

443 Views

In Python, we can sum the numbers present in a string list using various methods like using Regular Expressions, using isdigit() and List Comprehension, using Splitting and Joining etc. When working with lists containing strings in Python, it is common to come across situations where you need to extract and sum the numerical values from those strings. This can be particularly useful in situations such as processing data from text files, log files, or web scraping. In this article, we will understand these methods using different example and algorithms. Algorithm A general algorithm to find the sum of numbers ... Read More

Get the Number of Characters, Words, Spaces, and Lines in a File using Python

Rohan Singh
Updated on 17-Jul-2023 18:22:34

6K+ Views

Text file analysis is a fundamental task in various data processing and natural language processing applications. Python is a versatile and powerful programming language that provides numerous built−in features and libraries to facilitate such tasks efficiently. In this article, we will explore how to count the number of characters, words, spaces, and lines in a text file using Python. Method 1:Brute Force method In this method, we will develop our own logic in a brute−force manner and take a text file as input and count the number of characters, words, spaces, and lines in the file. In this method, we ... Read More

Get the indices of Uppercase Characters in a given String using Python

Rohan Singh
Updated on 17-Jul-2023 18:24:23

1K+ Views

In Python, we can get the indices of uppercase characters in a given string using methods like using List Comprehension, using a For Loop, using Regular Expressions etc. Finding the indices of Uppercase characters can be useful in text analysis and manipulation. In this article, we will explore different methods to obtain the indices of uppercase characters in a given string. Method 1:Using List Comprehension Using list comprehension we can iterate through the characters of a string, check if they are uppercase using the isupper() method, and stores their indices in a list. It provides a concise and ... Read More

Difference between CORBA and DCOM

Pranavnath
Updated on 18-Jul-2023 11:53:42

386 Views

The world of technology and programming has developed a variety of languages and frameworks, each with its functionality and purpose. This article examines the differences between these two great technologies. In this article, we will the concept of CORBA and DCOM and its difference. CORBA, which has a strong presence in the business field, and DCOM, Microsoft's technology, each have different characteristics. Understanding these differences is important for developers and businesses trying to make informed decisions about their tech stack. What is CORBA? CORBA (Common Object Request Broker Architecture) is a middleware innovation that empowers interoperability and communication between disseminated ... Read More

Filter Non-None dictionary keys in Python

Tapas Kumar Ghosh
Updated on 17-Jul-2023 18:26:27

264 Views

Python dictionary is one of the most popular data types among the following 4 datatypes. The dictionary defines the key with value pair and doesn’t allow the duplicate. The values are either strings or integers. Sometimes, while working on the dictionary it has some empty values that the None value can fill. For example- when we are working on a machine learning dataset it has found that some of the rows are empty and can be filled by the value None when performing the particular task. In Python, we have some built-in functions like items() and lambda that can be ... Read More

How to Filter list elements starting with a given Prefix using Python?

Tapas Kumar Ghosh
Updated on 17-Jul-2023 18:24:59

522 Views

The term prefix is defined by the beginning of the word or letter. In this article, we will learn how to use Python built-in functions like startswith(), filter(), lambda, and len() to Filter list elements starting with a given Prefix using Python. Let’s take an example to understand this − Let’s take an example to understand this: Given element list, My_list = [“Amelia”, “Kinshuk”, “Rosy”, “Aman”] Keyword to be searched, Prefix = “Am” Final result = [“Amelia”, “Aman”] Syntax The following syntax is used in all the examples − startswith() The is a built-in ... Read More

Advertisements