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

Dictionary (Edit Word): Tuple #126

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
39 changes: 23 additions & 16 deletions src/content/dictionary/tuple.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,27 @@
layout: ../../layouts/word.astro
title: "Tuple"
---

A tuple is a data structure that is an immutable, or unchangeable, ordered sequence of elements. Because tuples are immutable, their values cannot be modified.

As a general rule, tuples use less memory than a list or array.

Tuples allows for slicing and indexing like lists, but do not have methods for deleting or changing any elements.

**Example (Python)**

```python
# creating a tuple
mySiblings = ('Susan', 'James', 'Bryan')

# accessing an element within a tuple:

mySiblings[2]

A tuple is a data structure that is an immutable, or unchangeable, ordered sequence of elements. Because tuples are immutable, their values cannot be modified.

Generally, tuples use less memory than a list or array.

Tuples allow for slicing and indexing like lists but do not have methods for deleting or changing elements.

#### Key Characteristics of Tuples:

- **Immutable**: You cannot modify, add, or remove items after creating the tuple.
- **Ordered**: Items in a tuple maintain their defined order.
- **Can Store Different Data Types**: Each element in a tuple can be of any data type.
- **Supports Indexing**: Access elements using indices starting from 0.

**Example (Python)**

```python
# creating a tuple
mySiblings = ('Susan', 'James', 'Bryan')

# accessing an element within a tuple:

mySiblings[2]
```