Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 07.Tuple.md #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions 07.Tuple.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Lesson 7: Data Structures p.2 (`tuple`)

> Tuples are the static snapshots of data, providing a reliable and immutable record of information in code."
> "Tuples are the static snapshots of data, providing a reliable and immutable record of information in code."

## Content

Expand All @@ -12,7 +12,7 @@

## 1. Overview of Tuples

In `Python` a `tuple` - is an _immutable, ordered sequence of items_.
In `Python` a `tuple` is an _immutable, ordered sequence of items_.

Similar to `lists`, `tuples` can contain elements of different data types, but <span style="color:red"> _**cannot**_ be modified after their creation</span>.

Expand Down Expand Up @@ -124,11 +124,11 @@ ID after: 139653455025920

Yes, it's `Python` baby, but I promise, you will get used to this once understand the concept of objects and how do they work.

Note that `id` of the `tuple` hasn't changed, but `id` of the objects inside has.
Note that `id` of the `tuple` hasn't changed, but the content of the objects inside has.

## 2. Features Overview

Same as lists `Python` supports `indexing`, `slicing`, `concatenation`, `multiplication`, `unpacking` and some `built-in` functions.
Same as lists, `Python` tuples support `indexing`, `slicing`, `concatenation`, `multiplication`, `unpacking` and some `built-in` functions.

Suppose we have the following two tuples:

Expand Down Expand Up @@ -249,7 +249,7 @@ nums = (1, 2, 3)

## 3. Iterations

Typically we use tuples for stroing the _constants_.
Typically we use tuples for storing _constants_.

### 3.1 Using `for in`

Expand Down Expand Up @@ -296,7 +296,7 @@ Prime number at index 4 is 11

There is a built-in function called `enumerate()`, that adds a counter to an iterable.

It can be used with <span style="color:green"> any iterable</span>. and be particulary useful with when <span style="color:green"> both the element and its index </span> are needed.
It can be used with <span style="color:green"> any iterable</span> and be particulary useful when <span style="color:green"> both the element and its index </span> are needed.

```python
# Tuple of weekdays
Expand Down