Skip to content

Commit da83124

Browse files
Dictionary (Edit Word): Tuple (#126)
# Word #### Tuple # Updated Meaning/Definition 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] ``` --------- Co-authored-by: Olabode Lawal-Shittabey <babblebey@gmail.com>
1 parent 16a7fbd commit da83124

1 file changed

Lines changed: 26 additions & 21 deletions

File tree

src/content/dictionary/tuple.mdx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
---
2-
layout: ../../layouts/word.astro
3-
title: "Tuple"
4-
---
5-
6-
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.
7-
8-
As a general rule, tuples use less memory than a list or array.
9-
10-
Tuples allows for slicing and indexing like lists, but do not have methods for deleting or changing any elements.
11-
12-
**Example (Python)**
13-
14-
```python
15-
# creating a tuple
16-
mySiblings = ('Susan', 'James', 'Bryan')
17-
18-
# accessing an element within a tuple:
19-
20-
mySiblings[2]
21-
```
1+
---
2+
layout: ../../layouts/word.astro
3+
title: "Tuple"
4+
---
5+
6+
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.
7+
8+
Generally, tuples use less memory than a list or array. It allows for slicing and indexing like lists but do not have methods for deleting or changing elements.
9+
10+
#### Key Characteristics of Tuples:
11+
12+
- **Immutable**: You cannot modify, add, or remove items after creating the tuple.
13+
- **Ordered**: Items in a tuple maintain their defined order.
14+
- **Can Store Different Data Types**: Each element in a tuple can be of any data type.
15+
- **Supports Indexing**: Access elements using indices starting from 0.
16+
17+
**Example (Python):**
18+
19+
```python
20+
# creating a tuple
21+
mySiblings = ('Susan', 'James', 'Bryan')
22+
23+
# accessing an element within a tuple:
24+
mySiblings[2]
25+
```
26+

0 commit comments

Comments
 (0)