|
717 | 717 | "name": "stdout", |
718 | 718 | "output_type": "stream", |
719 | 719 | "text": [ |
720 | | - "['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc', 'ulp']\n" |
| 720 | + "['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'cbrt', 'ceil', 'comb', 'copysign', 'cos', 'cosh', 'degrees', 'dist', 'e', 'erf', 'erfc', 'exp', 'exp2', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'isqrt', 'lcm', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'nextafter', 'perm', 'pi', 'pow', 'prod', 'radians', 'remainder', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc', 'ulp']\n" |
721 | 721 | ] |
722 | 722 | } |
723 | 723 | ], |
|
1617 | 1617 | "cell_type": "markdown", |
1618 | 1618 | "metadata": {}, |
1619 | 1619 | "source": [ |
1620 | | - "## Use the ``SimpleNamespace`` method to store related variables (and keep things tidy)\n", |
| 1620 | + "## Use ``SimpleNamespace`` to store related variables (and keep things tidy)\n", |
1621 | 1621 | "\n", |
1622 | | - "Python ``SimpleNamespace`` method provides an easy way to store related variables and keep things tidy without the need of using a Python dictionary or generate a very large number of variables in the scope. ``SimpleNamespace`` has the advantage over Python dictionaries of accessing the values using the \"dot\" notation, this is using the syntax ``varname.attribute`` instead of ``varname['attribute']``.\n", |
| 1622 | + "Python ``SimpleNamespace`` method provides an easy way to store related variables and keep things tidy without the need of using a Python dictionary or generate a very large number of variables in the scope. The main practical difference between ``SimpleNamespace`` and Python dictionaries is that for ``SimpleNamespace`` objects we access the fields using the \"dot\" notation, this is using the syntax ``varname.attribute`` instead of ``varname['attribute']``.\n", |
1623 | 1623 | "\n", |
1624 | 1624 | "For example, imagine that we want to set a threesome of coordinates. In this case, instead of generating three different variables, it would be more convenient to use a single name called ``coordinates`` containing the different values of the coordinates within that _object_ called ``coordinates`` as follows" |
1625 | 1625 | ] |
|
2024 | 2024 | "source": [ |
2025 | 2025 | "# Python functions\n", |
2026 | 2026 | "\n", |
2027 | | - "A **function** in Python is a self-contained block of code that encapsulates a specific task or group of related tasks. We have already used several built-in Python functions in this notebook, e.g. ``print()``, or functions belonging to different modules such as ``math.log()``. Python allows the user to define their own functions. For this, first use the keyword ``def`` (meaning _define_) followed by the **name of the function**, a tuple which may be empty or contain one or multiple **arguments** or **parameters** of the function, and a colon. Below this, goes the (indented) code block that do the task(s) as follows\n", |
| 2027 | + "A **function** in Python is a compact self-contained block of code that executes some action (preferably) or group of actions. We have already used several built-in Python functions in this notebook, e.g. ``print()``, or functions belonging to different modules such as ``math.log()``. Python allows the user to define their own functions. For this, first use the keyword ``def`` (meaning _define_) followed by the **name of the function**, a tuple which may be empty or contain one or multiple **arguments** or **parameters** of the function, and a colon. Below this, goes the (indented) code block that do the task(s) as follows\n", |
2028 | 2028 | "\n", |
2029 | 2029 | "```python\n", |
2030 | 2030 | "def function_name(\"sequence of parameters if any\"):\n", |
|
2373 | 2373 | "name": "stdout", |
2374 | 2374 | "output_type": "stream", |
2375 | 2375 | "text": [ |
2376 | | - "Notebook tested in 2024-01-09 using:\n", |
2377 | | - "Python 3.10.13 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:15:57) [MSC v.1916 64 bit (AMD64)]\n" |
| 2376 | + "Notebook tested in 2024-02-20 using:\n", |
| 2377 | + "Python 3.11.5 | packaged by Anaconda, Inc. | (main, Sep 11 2023, 13:16:22) [MSC v.1916 64 bit (AMD64)]\n" |
2378 | 2378 | ] |
2379 | 2379 | } |
2380 | 2380 | ], |
|
2407 | 2407 | "name": "python", |
2408 | 2408 | "nbconvert_exporter": "python", |
2409 | 2409 | "pygments_lexer": "ipython3", |
2410 | | - "version": "3.10.13" |
| 2410 | + "version": "3.11.5" |
2411 | 2411 | } |
2412 | 2412 | }, |
2413 | 2413 | "nbformat": 4, |
|
0 commit comments