Python Data Structures: Strings, Lists, Tuples, and Dictionaries
Strings
A string stores textual data. Defined using single or double quotes.
integer_var = 100
string_var = "sample text"
Output Formatting
employee = 'Bob'
job_title = 'Developer'
office = 'Innovation Hub, Floor 3'
print('-------------------')
print(f"Name: {employee}")
print(f"Position: {job_title}")
print(f&qu ...
Posted on Tue, 04 Aug 2026 16:33:03 +0000 by ricardo.leite
Essential Methods for Python Strings, Lists, Tuples, Dictionaries, and Sets
String Operations
Whitespace Removal
text = '\n x yz \n'
print(text.strip()) # Removes leading and trailing whitespace and newlines
print(text.rstrip()) # Removes trailing whitespace only
print(text.lstrip()) # Removes leading whitespace only
Substitution
print(text.replace('x', 'X')) # Replaces all 'x' characters with 'X'
print(tex ...
Posted on Sat, 18 Jul 2026 16:57:46 +0000 by compphenom
Understanding Python Tuples: Immutability, Operations, and Comparison with Lists
Tuples in Python are ordered, immutable sequences that can store heterogeneous data. Their immutability makes them ideal for representing fixed collections of values.
Creating Tuples
Tuples are defined using parantheses () with comma-separated elements. An empty tuple is created with empty parentheses, and single-element tuples require a traili ...
Posted on Tue, 30 Jun 2026 18:15:35 +0000 by drfate
Understanding Destructuring in F#
F# is a modern, functional-first language within the .NET ecosystem that seamlessly integrates object-oriented and imperative paradigms. A key feature that enhances code readability and conciseness is destructuring. This technique allows developers to extract values from complex data structures and directly assign them to variables. This articl ...
Posted on Fri, 29 May 2026 23:40:37 +0000 by conor.higgins
Converting List Elements into Tuple Collections in Python
In Python, transforming individual list items in to tuple objects and organizing them into a new list involves iterating through the source collection and constructing tuple instances from each element. Here's a practical approach to accomplish this task:
Create a empty container to hold the resulting tuples.
Loop through the source collection ...
Posted on Sun, 10 May 2026 20:06:12 +0000 by fiddlehead_cons
Python Fundamentals: Variables, Data Structures, and Control Flow
Variables and Data Types
Variables
A variable name must start with a letter or undercsore, and can only contain letters, digits, and underscores. For instance, message_1 is valid, but 1_message is not.
Variable names cannot contain spaces; use underscores to seperate words. greeting_message works, while greeting message causes an error.
Avoid ...
Posted on Thu, 07 May 2026 04:12:03 +0000 by voltrader