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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Azeem Akhtar
Azeem Akhtar

Written by Azeem Akhtar

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

No responses yet

Write a response