Python Sequences and Collections

Azeem Akhtar
Aug 31, 2023

--

Photo by Chris Ried on Unsplash

Python offers several built-in data structures for working with sequences and collections of data. These data structures are crucial for organizing and manipulating data effectively. Some of the most commonly used ones include:

Lists: Lists are ordered collections that can hold items of different data types. They are defined using square brackets and can be modified after creation.

my_list = [1, 2, 3, 'hello', True]

Tuples: Tuples are similar to lists but are immutable, meaning their elements cannot be changed after creation. They are defined using parentheses and are often used for representing fixed sets of values.

my_tuple = (1, 2, 3, 'hello', True)

Strings: Strings are sequences of characters. They are also immutable, like tuples. Strings can be defined using single or double quotes.

my_string = "Hello, world!"

original published on https://pythonprox.blogspot.com/2023/08/python-sequences-and-collections.html

--

--

Azeem Akhtar
Azeem Akhtar

Written by Azeem Akhtar

Python, Machine Learning, Deep Learning, Data Science, Django, Artificial Intelligence

No responses yet