From 0e576fe38b5e67428c3dc69e688304be519a4c86 Mon Sep 17 00:00:00 2001 From: Sergei Nabatov Date: Mon, 8 Apr 2024 22:44:02 +0200 Subject: [PATCH 1/6] introduction update --- foundations/quickstart.ipynb | 196 +++++++---------------------------- 1 file changed, 36 insertions(+), 160 deletions(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index 435acd12f..b2b30d5b0 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -54,6 +54,35 @@ "print(\"Hello interweb\")" ] }, + { + "cell_type": "markdown", + "id": "37e18e9b", + "metadata": {}, + "source": [ + "## Variables in Python" + ] + }, + { + "cell_type": "markdown", + "id": "fc4470b6", + "metadata": {}, + "source": [ + "Variables are the containers for storing data. Variables could be simple and complex. They can represent the primitive data types and point to the other more sophisticated container, e.g. lists, dicts. Later in this notebook you can read the information about these complex types. \n", + "\n", + "As an example you can see a code block with both primitive data value and a complex one" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6b61c89f", + "metadata": {}, + "outputs": [], + "source": [ + "primitive_data = 5 # PRIMITIVE DATA VALUE\n", + "complex_data = [3, 4, 5] # COMPLEX DATA VALUE" + ] + }, { "cell_type": "markdown", "id": "4c7a126b", @@ -88,9 +117,9 @@ "source": [ "A few things to note:\n", "\n", - "- Python defaults to counting from 0 (like C) rather than from 1 (like Fortran).\n", - "- Function calls in Python always use parentheses: `print()`\n", - "- The colon `:` denotes the beginning of a definition (here of the repeated code under the `for` loop).\n", + "- As the reader can see from the output, n starts from 0 (inclusively) to 3 (exclusively). It means that by default iteration starts from 0 if not specified\n", + "- Function calls in Python use parentheses: `print()`\n", + "- The colon `:` denotes the beginning of a new code block (here of the repeated code under the `for` loop).\n", "- Code blocks are identified through indentations.\n", "\n", "To emphasize this last point, here is an example with a two-line repeated block:" @@ -189,7 +218,7 @@ "source": [ "### Integers (`int`)\n", "\n", - "The number `m` above is a good example. We can use the built-in function `type()` to inspect what we've got in memory:" + "The variable `m` above is a good example. We can use the function `type()` to examine the type of variable" ] }, { @@ -303,7 +332,7 @@ "id": "271edb6e", "metadata": {}, "source": [ - "Lists are useful for lots of reasons including iteration:" + "Lists are useful for lots of reasons. As an example, lists could be used for iteration" ] }, { @@ -368,7 +397,7 @@ "id": "87e841a7", "metadata": {}, "source": [ - "remembering that we start counting from zero!" + "Remember that every index in Python starts at 0" ] }, { @@ -397,7 +426,7 @@ "source": [ "### Dictionaries (`dict`)\n", "\n", - "A dictionary is a collection of *labeled objects*. Python uses curly braces `{}` to create dictionaries:" + "A dictionary is a collection of *labeled objects*. While list is an *ordered* container, the dictionary is an *unordered* one. It means that the elements in the container do not presume the order. Python uses curly braces `{}` to create dictionaries:" ] }, { @@ -453,159 +482,6 @@ " print(\"The value is:\", mypet[key])" ] }, - { - "cell_type": "markdown", - "id": "fb82a430", - "metadata": {}, - "source": [ - "## Arrays of numbers with NumPy\n", - "\n", - "The vast majority of scientific Python code makes use of *packages* that extend the base language in many useful ways.\n", - "\n", - "Almost all scientific computing requires ordered arrays of numbers, and fast methods for manipulating them. That's what [NumPy](../core/numpy.md) does in the Python world.\n", - "\n", - "Using any package requires an `import` statement, and (optionally) a nickname to be used locally, denoted by the keyword `as`:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "53ba88cf", - "metadata": {}, - "outputs": [], - "source": [ - "import numpy as np" - ] - }, - { - "cell_type": "markdown", - "id": "fb237b33", - "metadata": {}, - "source": [ - "Now all our calls to `numpy` functions will be preceeded by `np.`" - ] - }, - { - "cell_type": "markdown", - "id": "a3391f8d", - "metadata": {}, - "source": [ - "Create a linearly space array of numbers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "ae024132", - "metadata": {}, - "outputs": [], - "source": [ - "# linspace() takes 3 arguments: start, end, total number of points\n", - "numbers = np.linspace(0.0, 1.0, 11)\n", - "numbers" - ] - }, - { - "cell_type": "markdown", - "id": "cc1c2474", - "metadata": {}, - "source": [ - "We've just created a new type of object defined by [NumPy](../core/numpy.md):" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "c3f3642d", - "metadata": {}, - "outputs": [], - "source": [ - "type(numbers)" - ] - }, - { - "cell_type": "markdown", - "id": "83325c40", - "metadata": {}, - "source": [ - "Do some arithmetic on that array:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "12cc225d", - "metadata": {}, - "outputs": [], - "source": [ - "numbers + 1" - ] - }, - { - "cell_type": "markdown", - "id": "fee4e53c", - "metadata": {}, - "source": [ - "Sum up all the numbers:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "3cef5412", - "metadata": {}, - "outputs": [], - "source": [ - "np.sum(numbers)" - ] - }, - { - "cell_type": "markdown", - "id": "ebf2b669", - "metadata": {}, - "source": [ - "## Some basic graphics with Matplotlib\n", - "\n", - "[Matplotlib](../core/matplotlib.md) is the standard package for producing publication-quality graphics, and works hand-in-hand with [NumPy](../core/numpy.md) arrays.\n", - "\n", - "We usually use the `pyplot` submodule for day-to-day plotting commands:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "76f3329e", - "metadata": {}, - "outputs": [], - "source": [ - "import matplotlib.pyplot as plt" - ] - }, - { - "cell_type": "markdown", - "id": "66033cbc", - "metadata": {}, - "source": [ - "Define some data and make a line plot:" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "32ca697e", - "metadata": {}, - "outputs": [], - "source": [ - "theta = np.linspace(0.0, 360.0)\n", - "sintheta = np.sin(np.deg2rad(theta))\n", - "\n", - "plt.plot(theta, sintheta, label='y = sin(x)', color='purple')\n", - "plt.grid()\n", - "plt.legend()\n", - "plt.xlabel('Degrees')\n", - "plt.title('Our first Pythonic plot', fontsize=14)" - ] - }, { "cell_type": "markdown", "id": "04615882", From 31938392544d01d6c5bb6473169d44231a2ac92a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 14 Apr 2024 17:01:59 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- foundations/quickstart.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index b2b30d5b0..499f6b6a5 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -79,8 +79,8 @@ "metadata": {}, "outputs": [], "source": [ - "primitive_data = 5 # PRIMITIVE DATA VALUE\n", - "complex_data = [3, 4, 5] # COMPLEX DATA VALUE" + "primitive_data = 5 # PRIMITIVE DATA VALUE\n", + "complex_data = [3, 4, 5] # COMPLEX DATA VALUE" ] }, { From 4510e3a72bcb7954cedc24cc6ba7a0599f251f00 Mon Sep 17 00:00:00 2001 From: Sergei Nabatov Date: Sat, 20 Apr 2024 16:31:34 +0200 Subject: [PATCH 3/6] Update foundations/quickstart.ipynb - 1 suggestion Co-authored-by: Julia Kent <46687291+jukent@users.noreply.github.com> --- foundations/quickstart.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index 499f6b6a5..26c89abfe 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -117,7 +117,7 @@ "source": [ "A few things to note:\n", "\n", - "- As the reader can see from the output, n starts from 0 (inclusively) to 3 (exclusively). It means that by default iteration starts from 0 if not specified\n", + "- As the reader can see from the output, `n` starts from 0 (inclusively) to 3 (exclusively). This indicates that by default iteration starts from 0 (if not otherwise specified)\n", "- Function calls in Python use parentheses: `print()`\n", "- The colon `:` denotes the beginning of a new code block (here of the repeated code under the `for` loop).\n", "- Code blocks are identified through indentations.\n", From e7dee41be3773218547991fdd18be6bda131ffc0 Mon Sep 17 00:00:00 2001 From: Sergei Nabatov Date: Sat, 20 Apr 2024 16:31:45 +0200 Subject: [PATCH 4/6] Update foundations/quickstart.ipynb - 2 suggestion Co-authored-by: Julia Kent <46687291+jukent@users.noreply.github.com> --- foundations/quickstart.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index 26c89abfe..c784982af 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -397,7 +397,7 @@ "id": "87e841a7", "metadata": {}, "source": [ - "Remember that every index in Python starts at 0" + "Remember that every index in Python starts at 0." ] }, { From 86d0fe88e8063ac68cc0dc68649ced8dc5cc768a Mon Sep 17 00:00:00 2001 From: Sergei Nabatov Date: Sat, 20 Apr 2024 16:31:55 +0200 Subject: [PATCH 5/6] Update foundations/quickstart.ipynb - 3 suggestion Co-authored-by: Julia Kent <46687291+jukent@users.noreply.github.com> --- foundations/quickstart.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index c784982af..53ae11ab7 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -426,7 +426,7 @@ "source": [ "### Dictionaries (`dict`)\n", "\n", - "A dictionary is a collection of *labeled objects*. While list is an *ordered* container, the dictionary is an *unordered* one. It means that the elements in the container do not presume the order. Python uses curly braces `{}` to create dictionaries:" + "A dictionary is a collection of *labeled objects*. While a list is an *ordered* container, the dictionary is an *unordered* one, meaning that the elements in the container do not presume the order. Dictionary elements are accessed via their "key" rather than their index. Python uses curly braces `{}` to create dictionaries:" ] }, { From ab3351ae602fd5a96c7eeabcc8da69a781d63533 Mon Sep 17 00:00:00 2001 From: Sergei Nabatov Date: Sat, 20 Apr 2024 16:41:11 +0200 Subject: [PATCH 6/6] update the quotes --- foundations/quickstart.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foundations/quickstart.ipynb b/foundations/quickstart.ipynb index 53ae11ab7..cfd1c28ba 100644 --- a/foundations/quickstart.ipynb +++ b/foundations/quickstart.ipynb @@ -426,7 +426,7 @@ "source": [ "### Dictionaries (`dict`)\n", "\n", - "A dictionary is a collection of *labeled objects*. While a list is an *ordered* container, the dictionary is an *unordered* one, meaning that the elements in the container do not presume the order. Dictionary elements are accessed via their "key" rather than their index. Python uses curly braces `{}` to create dictionaries:" + "A dictionary is a collection of *labeled objects*. While a list is an *ordered* container, the dictionary is an *unordered* one, meaning that the elements in the container do not presume the order. Dictionary elements are accessed via their \"key\" rather than their index. Python uses curly braces `{}` to create dictionaries:" ] }, {