Articles on Trending Technologies

Technical articles with clear explanations and examples

SQL using Python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 1K+ Views

In this tutorial, we are going to learn how to use SQL with Python using SQLite database. Python has a built-in module to connect with SQLite database. We are going to use sqlite3 module to connect Python and SQLite. We have to follow the below steps to connect the SQLite database with Python ? Import the sqlite3 module. Create a connection using the sqlite3.connect(db_name) method that takes a database name as an argument. It creates one file if it doesn't exist with the given name else it opens the file with ...

Read More

Split a string in equal parts (grouper in Python)

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 410 Views

In this tutorial, we will learn how to split a string into equal-sized parts using Python. This technique is often called a "grouper" function and is useful for processing data in chunks. Problem Overview Given a string and a desired chunk size, we want to divide the string into equal parts. If the string length is not evenly divisible, we'll pad the last chunk with a fill character. Example 1 Split 'Tutorialspoint' into chunks of 5 characters ? string = 'Tutorialspoint' each_part_length = 5 print(f"Input: '{string}' with chunk size {each_part_length}") Input: ...

Read More

Set update() in Python to do union of n arrays

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 379 Views

In this tutorial, we will use the set.update() method to find the union of multiple arrays. This method efficiently combines arrays while automatically removing duplicates, returning a one-dimensional array with all unique values. What is set.update()? The update() method adds elements from an iterable (like a list or array) to an existing set. It automatically handles duplicates by keeping only unique values. Syntax set.update(iterable) Example Let's see how to union multiple arrays using set.update() ? # initializing the arrays arrays = [[1, 2, 3, 4, 5], [6, 7, 8, 1, ...

Read More

Send SMS updates to mobile phone using python

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we are going to learn how to send SMS messages in Python using the Twilio API service. Twilio provides a simple and reliable way to send SMS messages programmatically. Setting Up Twilio Account First, go to Twilio and create an account. You will get a free trial account with some credits to test SMS functionality. Complete the account setup and verify your phone number. Installation Install the twilio module using pip ? pip install twilio Getting Twilio Credentials From your Twilio Console Dashboard, you need to collect ? ...

Read More

self in Python class

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we are going to learn about self in Python classes. The self parameter is a reference to the current instance of a class and is used to access variables and methods belonging to that instance. Note − self is not a keyword in Python. What is self? We use self in classes to represent the instance of an object. We can create multiple instances of a class and each instance will have different values. The self parameter helps us access those property values within the class instance. Basic Example Let's see how ...

Read More

Calculate difference between adjacent elements in given list using Python

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 1K+ Views

Calculating the difference between adjacent elements in a list is a common task in data analysis. Python provides several efficient approaches to solve this problem using list comprehension, loops, or built-in functions. Problem Definition Given a list, we need to calculate the difference between each adjacent pair of elements (next element minus current element). The result will have one fewer element than the original list. Example Scenario Input: [10, 15, 12, 18] Output: [5, -3, 6] Explanation: 15 - 10 = 5 12 - 15 = -3 18 - 12 = 6 ...

Read More

Alternate element summation in list (Python)

Yaswanth Varma
Yaswanth Varma
Updated on 25-Mar-2026 993 Views

The given task is to perform an alternate summation on a Python List. For example, adding the elements at even indices (0, 2, 4) or odd indices (1, 3, 5), depending on the requirement. This means we need to add every other element from the given list. Let us see an input scenario − Scenario Input: [11, 22, 33, 44, 55] Output: 99 Explanation: Here, we are going to add the elements at the even indices by using the slicing [::2]. Using sum() with List Slicing The alternate element summation in a list can ...

Read More

Python Grouped Flattening of list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 232 Views

In this tutorial, we will write a program that performs grouped flattening of a list containing sub-lists. This technique groups consecutive sublists together and flattens them into single lists, creating chunks of a specified size. Problem Statement Given a list of sublists and a number, we need to group the sublists in chunks of the given number and flatten each group into a single list. Input lists = [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10]] number = 2 Expected Output [[1, 2, 3, 4], [5, 6, 7, 8], ...

Read More

Python How to copy a nested list

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 540 Views

In this tutorial, we are going to see different ways to copy a nested list in Python. A nested list is a list that contains other lists as elements. When copying nested lists, we need to create independent copies of both the outer list and inner lists to avoid unwanted modifications. Let's explore three effective methods to achieve this ? Using Nested Loops The most straightforward approach uses nested loops to manually copy each element ? # initializing a list nested_list = [[1, 2], [3, 4], [5, 6, 7]] # empty list copy_list = ...

Read More

Python Indexing a sublist

Hafeezul Kareem
Hafeezul Kareem
Updated on 25-Mar-2026 2K+ Views

In this tutorial, we will learn how to find the index of a sublist that contains a specific element. This is useful when working with nested lists where you need to locate which sublist contains your target element. Problem Statement Given a nested list, we need to find the index of the sublist that contains a specific element ? nested_list = [[1, 2, 3], [4, 5], [6, 7, 8, 9]] Expected output for elements 7, 5, and 3 ? Index of 7: 2 Index of 5: 1 Index of 3: 0 ...

Read More
Showing 1–10 of 61,304 articles
« Prev 1 2 3 4 5 6131 Next »
Advertisements