Programming Articles

Page 62 of 2547

Create list of Tuples using for Loop using Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 1K+ Views

Python's key data structures are lists and tuples. Tuples are immutable collections where elements cannot be changed once set, while lists can be modified after initialization. When dealing with data that needs to be grouped together, a for loop is commonly used to create lists of tuples. This tutorial demonstrates creating a list of tuples using a for loop, simplifying repetitive data organization tasks. Syntax for variable in iterable: # loop code Basic Operations on Tuples Creating and Accessing Tuples # Initializing tuples my_tuple = (1, 2, "Hello", ...

Read More

How to Create a Dictionary Of Tuples in Python

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 2K+ Views

A dictionary of tuples in Python combines the key-value structure of dictionaries with the immutable, ordered nature of tuples. This creates an efficient way to store multiple related values for each key, such as student information, product details, or coordinates. Syntax The basic syntax for creating a dictionary of tuples is ? dictionary_name = { key1: (value1_1, value1_2, ...), key2: (value2_1, value2_2, ...), key3: (value3_1, value3_2, ...) } Basic Example Let's create a dictionary storing student names and their test scores ...

Read More

How to Create Acronyms from Words Using Python

Akshitha Mote
Akshitha Mote
Updated on 27-Mar-2026 4K+ Views

An acronym is an abbreviated version of a phrase formed by taking the first character of each word. For example, "CPU" is an acronym for "Central Processing Unit". In this article, we will learn different methods to create acronyms from words using Python. Example Scenario Input: "Automatic Teller Machine" Output: "ATM" Explanation: The acronym is created by taking the first character of each word: A-T-M. Algorithm to Create Acronyms The following steps create acronyms from words using Python − Split the input string into individual words using split() ...

Read More

Python - Create a string made of the first and last two characters from a given string

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 3K+ Views

This tutorial demonstrates how to create a new string using the first and last two characters from a given string through string slicing. This technique is useful for data processing, text formatting, and extracting key information from strings. Algorithm Start with the given string Use slicing [:2] to extract the first two characters Use negative slicing [-2:] to extract the last two characters Concatenate both parts to form the new string Basic Example Here's the simple approach to create a new string ...

Read More

How to Create a List of Tuples in Python?

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 515 Views

In Python, creating a list of tuples is a flexible approach for storing related data items together. Tuples are immutable, ordered collections that are perfect for grouping related information like coordinates, records, or key-value pairs. Basic List of Tuples Creation The simplest way to create a list of tuples is by directly defining them ? # Create a list of tuples containing student records student_records = [ ("Alice Johnson", 25, "A"), ("Bob Smith", 21, "B"), ("Charlie Brown", 23, "A"), ] # Iterate through ...

Read More

Python - Odd Frequency Characters

Sai Mohan Pulamolu
Sai Mohan Pulamolu
Updated on 27-Mar-2026 578 Views

In Python, fetching characters with odd frequencies from a given string can be a very common task in text processing and data analysis. In this article, we will learn various methods to fetch the odd frequency characters of a string in Python. Using a Dictionary Dictionaries are very convenient when there is a need to keep track of the frequencies of elements. We can manually count each character's occurrences and filter those with odd frequencies. Approach To get the odd frequency elements, we will iterate through the entire string, and for each character in the string, ...

Read More

Create a box in Python GTK+ 3

Atharva Shah
Atharva Shah
Updated on 27-Mar-2026 2K+ Views

GTK+ 3 is a sophisticated graphical user interface library for creating cross-platform desktop applications. It provides an extensive range of tools and widgets for building interactive and appealing GUIs. Let's explore how to create and use box layouts in GTK+ 3 to organize widgets within a window. Setup and Installation For Windows users, install the Windows Subsystem for Linux (WSL) to use Linux commands and PyGObject in Windows environments. This simplifies access to libraries and GObject Introspection bindings. Install the required packages: pip install PyGObject sudo apt install libcairo2-dev python3-gi gir1.2-gtk-3.0 gcc libgirepository1.0-dev gobject-introspection pkg-config ...

Read More

Opening Links Using Selenium in Python

Sai Mohan Pulamolu
Sai Mohan Pulamolu
Updated on 27-Mar-2026 3K+ Views

When working with automation tasks, opening links programmatically is a very common requirement. Selenium, a popular web testing framework, provides powerful tools to handle web pages and perform various actions like opening links. In this article, we will learn various methods to open links in Selenium using Python. Prerequisites Before we get started, make sure that you have the following software installed: Python: Install Python, if you haven't already. Selenium: Install Selenium by running pip install selenium in your command prompt. Web Driver: Selenium requires a web driver to interface with the chosen browser. You need ...

Read More

Iterate Through List of Dictionaries in Python

Sai Mohan Pulamolu
Sai Mohan Pulamolu
Updated on 27-Mar-2026 11K+ Views

In this article, we will learn various methods to iterate through a list of dictionaries in Python. When working with data in Python, it is very common to encounter scenarios where you have a list of dictionaries. Each dictionary represents an individual data entry, and you need to perform operations or extract specific information from these dictionaries. Using a For Loop and Dictionary Access Methods The most straightforward approach is to use a for loop to iterate through each dictionary in the list. Inside the loop, we can use dictionary access methods like keys(), values(), or items() to ...

Read More

Iterate Over Words of a String in Python

Sai Mohan Pulamolu
Sai Mohan Pulamolu
Updated on 27-Mar-2026 2K+ Views

In Python, iterating over words in a string is a fundamental skill for text processing and analysis. This article explores various methods to split strings into words and iterate through them efficiently. Using split() Method Syntax string.split(separator, maxsplit) The split() method takes two optional parameters: separator and maxsplit. By default, the separator is any whitespace, and maxsplit is −1, which means the method will split the string at every occurrence of the separator. Example text = "Welcome to tutorials point." words = text.split() print(words) ['Welcome', 'to', 'tutorials', 'point.'] ...

Read More
Showing 611–620 of 25,469 articles
« Prev 1 60 61 62 63 64 2547 Next »
Advertisements