<jupyter_start><jupyter_text>(tuples)= Tuples``` {index} Tuples (python)```Tuples are constant lists. They can be used like lists to store data but they cannot be modified (they are immutable). They are used for storing multiple values from functions. They are created like lists, but with round brackets:```python    tuple1 = (variable1, variable2, variable3)```   Tuples can have as many elements as you want and they don't have to be of the same type. Tuples are used, for example, in string formatting syntax:    ```python    print("text %g, %g" % (no1, no2))  (no1, no2) is a tuple```    For functions that return multiple values, values from tuples can be extracted with this syntax:```python    value1, value2 = function1(some_variable)```<jupyter_code>t = (2, 4, 6, 'temp.pdf')   # Create a tuple.
t =  2, 4, 6, 'temp.pdf'    # Create a tuple, without bracket

print(t[3])                 # Indexing as usual<jupyter_output>temp.pdf<jupyter_text>What is the purpose of tuples, when lists have more functionality?- Tuples cannot be modified, even by accident.- They are faster than lists.- Widely used in Python.- Can be used as keys in dictionaries, while lists can't. (tuples_exercises)= Exercises--------------* **Define a function** which will return both maximum and minimum in terms of lexicographical order of a list consisting of tuples (pairs).**HINT**: in lexicographical order \\((a_1,b_1) > (a_2,b_2)\\) if and only if \\(a_1 > a_2\\) or \\((a_1 = a_2\\) and \\(b_1 > b_2) \\)<jupyter_code>l = [(1,2), (1,3), (0,7), (0,5)] 
# here (1,3) is maximum and (0,5) is min<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13267203967761934, 'fraction_numerical': 0.024798512089274645, 'mean_word_length': 4.0754716981132075, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '451379', 'license': 'MIT', 'n_tokens_mistral': 532, 'n_tokens_neox': 506, 'n_words': 217, 'path': 'notebooks/b_coding/Intro to Python/12_Tuples.ipynb', 'repo_name': 'primer-computational-mathematics/book', 'size': '1613'}