[Cater Waiter & Sets Concept]: Better Differentiation of Emoji Examples in Introduction & About Files (#3991)
* Changed emoji examples in indtroduction to be more differentiated. * Differentiated emoji examples in about.md doc as well. * Change one more example to differentiate.
This commit is contained in:
@@ -34,12 +34,13 @@ While sets can be created in many different ways, the most straightforward const
|
|||||||
A `set` can be directly entered as a _set literal_ with curly `{}` brackets and commas between elements.
|
A `set` can be directly entered as a _set literal_ with curly `{}` brackets and commas between elements.
|
||||||
Duplicates are silently omitted:
|
Duplicates are silently omitted:
|
||||||
|
|
||||||
```python
|
|
||||||
>>> one_element = {'😀'}
|
|
||||||
{'😀'}
|
|
||||||
|
|
||||||
>>> multiple_elements = {'😀', '😃', '😄', '😁'}
|
```python
|
||||||
{'😀', '😃', '😄', '😁'}
|
>>> one_element = {'➕'}
|
||||||
|
{'➕'}
|
||||||
|
|
||||||
|
>>> multiple_elements = {'➕', '🔻', '🔹', '🔆'}
|
||||||
|
{'➕', '🔻', '🔹', '🔆'}
|
||||||
|
|
||||||
>>> multiple_duplicates = {'Hello!', 'Hello!', 'Hello!',
|
>>> multiple_duplicates = {'Hello!', 'Hello!', 'Hello!',
|
||||||
'¡Hola!','Привіт!', 'こんにちは!',
|
'¡Hola!','Привіт!', 'こんにちは!',
|
||||||
@@ -108,9 +109,9 @@ Remember: sets can hold different datatypes and _nested_ datatypes, but all `set
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Attempting to use a list for a set member throws a TypeError
|
# Attempting to use a list for a set member throws a TypeError
|
||||||
>>> lists_as_elements = {['😅','🤣'],
|
>>> lists_as_elements = {['🌈','💦'],
|
||||||
['😂','🙂','🙃'],
|
['☁️','⭐️','🌍'],
|
||||||
['😜', '🤪', '😝']}
|
['⛵️', '🚲', '🚀']}
|
||||||
|
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
@@ -118,9 +119,9 @@ TypeError: unhashable type: 'list'
|
|||||||
|
|
||||||
|
|
||||||
# Standard sets are mutable, so they cannot be hashed.
|
# Standard sets are mutable, so they cannot be hashed.
|
||||||
>>> sets_as_elements = {{'😅','🤣'},
|
>>> sets_as_elements = {{'🌈','💦'},
|
||||||
{'😂','🙂','🙃'},
|
{'☁️','⭐️','🌍'},
|
||||||
{'😜', '🤪', '😝'}}
|
{'⛵️', '🚲', '🚀'}}
|
||||||
|
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
@@ -131,14 +132,15 @@ However, a `set` of `sets` can be created via type `frozenset()`:
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Frozensets don't have a literal form.
|
# Frozensets don't have a literal form.
|
||||||
>>> set_1 = frozenset({'😜', '😝', '🤪'})
|
>>> set_1 = frozenset({'🌈','💦'})
|
||||||
>>> set_2 = frozenset({'😅', '🤣'})
|
>>> set_2 = frozenset({'☁️','⭐️','🌍'})
|
||||||
>>> set_3 = frozenset({'😂', '🙂', '🙃'})
|
>>> set_3 = frozenset({'⛵️', '🚲', '🚀'})
|
||||||
|
|
||||||
>>> frozen_sets_as_elements = {set_1, set_2, set_3}
|
>>> frozen_sets_as_elements = {set_1, set_2, set_3}
|
||||||
>>> frozen_sets_as_elements
|
>>> frozen_sets_as_elements
|
||||||
{frozenset({'😜', '😝', '🤪'}), frozenset({'😅', '🤣'}),
|
{frozenset({'⛵️', '🚀', '🚲'}),
|
||||||
frozenset({'😂', '🙂', '🙃'})}
|
frozenset({'🌈', '💦'}),
|
||||||
|
frozenset({'☁️', '⭐️', '🌍'})}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ A `set` can be directly entered as a _set literal_ with curly `{}` brackets and
|
|||||||
Duplicates are silently omitted:
|
Duplicates are silently omitted:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
>>> one_element = {'😀'}
|
>>> one_element = {'➕'}
|
||||||
{'😀'}
|
{'➕'}
|
||||||
|
|
||||||
>>> multiple_elements = {'😀', '😃', '😄', '😁'}
|
>>> multiple_elements = {'➕', '🔻', '🔹', '🔆'}
|
||||||
{'😀', '😃', '😄', '😁'}
|
{'➕', '🔻', '🔹', '🔆'}
|
||||||
|
|
||||||
>>> multiple_duplicates = {'Hello!', 'Hello!', 'Hello!',
|
>>> multiple_duplicates = {'Hello!', 'Hello!', 'Hello!',
|
||||||
'¡Hola!','Привіт!', 'こんにちは!',
|
'¡Hola!','Привіт!', 'こんにちは!',
|
||||||
@@ -91,9 +91,9 @@ Sets can hold different datatypes and _nested_ datatypes, but all `set` elements
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
# Attempting to use a list for a set member throws a TypeError
|
# Attempting to use a list for a set member throws a TypeError
|
||||||
>>> lists_as_elements = {['😅','🤣'],
|
>>> lists_as_elements = {['🌈','💦'],
|
||||||
['😂','🙂','🙃'],
|
['☁️','⭐️','🌍'],
|
||||||
['😜', '🤪', '😝']}
|
['⛵️', '🚲', '🚀']}
|
||||||
|
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
@@ -101,9 +101,9 @@ TypeError: unhashable type: 'list'
|
|||||||
|
|
||||||
|
|
||||||
# Standard sets are mutable, so they cannot be hashed.
|
# Standard sets are mutable, so they cannot be hashed.
|
||||||
>>> sets_as_elements = {{'😅','🤣'},
|
>>> sets_as_elements = {{'🌈','💦'},
|
||||||
{'😂','🙂','🙃'},
|
{'☁️','⭐️','🌍'},
|
||||||
{'😜', '🤪', '😝'}}
|
{'⛵️', '🚲', '🚀'}}
|
||||||
|
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<stdin>", line 1, in <module>
|
File "<stdin>", line 1, in <module>
|
||||||
|
|||||||
Reference in New Issue
Block a user