Working with Python Lists and Tuples
A list is an ordered, mutable collection that can hold elements of any type, including other lists.
Creating Lists
Lists can be created through direct definition, for loops, and list comprehensions.
Direct Definition
Use square brackets [].
sample_list = [1, 2, 'hello', [3, 4], (5,), {'data': 100}]
Using a For Loop
num_list = []
for j in range ...
Posted on Fri, 02 Oct 2026 16:10:08 +0000 by leap500
Python Collections Module: Specialized Container Types
Collections Module Overview
The collections module provides specialized container alternatives to Python's built-in containers like list, dict, set, and tuple. Key components include:
namedtuple: Creates tuple subclasses with named fields
deque: Double-ended queue for efficient appends/pops
Counter: Dictionary subclass for counting hashable ob ...
Posted on Mon, 14 Sep 2026 16:35:40 +0000 by L
Python Tuple, Dictionary, and Set: Built-in Methods and Data Types
Tuple Built-in Methods
A tuple is an immutable sequence type—essentially a list that cannot be modified after creation. Once defined, its contents are fixed.
Purpose
Tuples store multiple values in a single container, providing memory efficiency through immutability.
Definition Syntax
Tuples are created using parentheses with elements separated ...
Posted on Thu, 27 Aug 2026 16:17:46 +0000 by glassroof
Understanding Data Type Conversions in Python
Python supports several core data types, each with distinct characteristics:
Numeric Types: int, float, bool, complex
Strings: Enclosed in single or double quotes, using ASCII characters
Lists: Ordered, mutable collections of items separated by commas
Tuples: Ordered, immutable collections enclosed in parentheses
Dictionaries: Key-value pairs ...
Posted on Sat, 27 Jun 2026 16:13:37 +0000 by mlpeters5403
Internal Implementation Mechanisms of std::tuple in C++
The storage design of std::tuple relies on a recursive inheritance model. A tuple with N elements (where N > 0) is implemented as a derived class that privately inherits from a base class representing a tuple of the remaining N-1 elements. The terminal case is an empty tuple specialization for zero elements. Consider the following instantiat ...
Posted on Fri, 22 May 2026 19:57:43 +0000 by wobbit