mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): update example codes for set and tuple (#66282)
This commit is contained in:
+8
-8
@@ -69,11 +69,11 @@ my_boolean_var = True
|
||||
print('Boolean:', my_boolean_var) # Boolean: True
|
||||
```
|
||||
|
||||
- Set: An unordered collection of unique elements, like `{4, 2, 0}`.
|
||||
- Set: An unordered collection of unique elements, like `{0.5, 4, 'apple'}`.
|
||||
|
||||
```python
|
||||
my_set_var = {7, 5, 8}
|
||||
print('Set:', my_set_var) # Set: {7, 5, 8}
|
||||
my_set_var = {7, 'hello', 8.5}
|
||||
print('Set:', my_set_var) # Set: {7, 'hello', 8.5}
|
||||
```
|
||||
|
||||
- Dictionary: A collection of key-value pairs enclosed in curly braces, like `{'name': 'John Doe', 'age': 28}`.
|
||||
@@ -83,11 +83,11 @@ my_dictionary_var = {'name': 'Alice', 'age': 25}
|
||||
print('Dictionary:', my_dictionary_var) # Dictionary: {'name': 'Alice', 'age': 25}
|
||||
```
|
||||
|
||||
- Tuple: An immutable ordered collection, enclosed in brackets, like `(7, 8, 4)`.
|
||||
- Tuple: An immutable ordered collection, enclosed in parentheses, like `('apple', 4.5, 7)`.
|
||||
|
||||
```python
|
||||
my_tuple_var = (7, 5, 8)
|
||||
print('Tuple:', my_tuple_var) # Tuple: (7, 5, 8)
|
||||
my_tuple_var = (7, 'hello', 8.5)
|
||||
print('Tuple:', my_tuple_var) # Tuple: (7, 'hello', 8.5)
|
||||
```
|
||||
|
||||
- Range: A sequence of numbers, often used in loops, for example, `range(5)`.
|
||||
@@ -136,13 +136,13 @@ print(type(my_string_var)) # <class 'str'>
|
||||
my_boolean_var = True
|
||||
print(type(my_boolean_var)) # <class 'bool'>
|
||||
|
||||
my_set_var = {7, 5, 8}
|
||||
my_set_var = {7, 'hello', 8.5}
|
||||
print(type(my_set_var)) # <class 'set'>
|
||||
|
||||
my_dictionary_var = {'name': 'Alice', 'age': 25}
|
||||
print(type(my_dictionary_var)) # <class 'dict'>
|
||||
|
||||
my_tuple_var = (7, 5, 8)
|
||||
my_tuple_var = (7, 'hello', 8.5)
|
||||
print(type(my_tuple_var)) # <class 'tuple'>
|
||||
|
||||
my_range_var = range(5)
|
||||
|
||||
Reference in New Issue
Block a user