From 99baca9caee30d65cb68aad86a134e0a7f66fbb3 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 18 May 2026 11:54:09 +0100 Subject: [PATCH 1/3] Add tuple unpacking example Add tuple unpacking example Includes example for oneline variable definition, but also a more real example --- Intermediate.ipynb | 33 ++++++++++++++++++++++++ Intermediate_full.ipynb | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/Intermediate.ipynb b/Intermediate.ipynb index f9389fd..c3b1f19 100644 --- a/Intermediate.ipynb +++ b/Intermediate.ipynb @@ -2305,6 +2305,39 @@ "# Initialising a tuple with one value\n" ] }, + { + "cell_type": "markdown", + "id": "812d5a14", + "metadata": { + "editable": false, + "slideshow": { + "slide_type": "fragment" + }, + "tags": [] + }, + "source": [ + "Tuple Unpacking" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "22e2a236-df2d-4130-9810-5bfd4f0ccb49", + "metadata": { + "editable": true, + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# The most basic example of tuple unpacking\n", + "\n", + "# You can use tuple unpacking when a function returns multiple values, or a tuple!\n" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/Intermediate_full.ipynb b/Intermediate_full.ipynb index a7ea66c..2e3494f 100644 --- a/Intermediate_full.ipynb +++ b/Intermediate_full.ipynb @@ -2251,6 +2251,62 @@ "print(my_tuple)" ] }, + { + "cell_type": "markdown", + "id": "812d5a14", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "fragment" + }, + "tags": [] + }, + "source": [ + "Tuple Unpacking" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "22e2a236-df2d-4130-9810-5bfd4f0ccb49", + "metadata": { + "editable": true, + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "# The most basic example of tuple unpacking\n", + "a, b = 1, 2\n", + "print(a)\n", + "\n", + "# You can use tuple unpacking when a function returns multiple values, or a tuple!\n", + "def get_full_name():\n", + " return \"First\", \"Last\"\n", + "\n", + "first, last = get_full_name()\n", + "print(first, last)" + ] + }, + { + "cell_type": "markdown", + "id": "4ef4d631-b632-4712-a659-ed59f03c676b", + "metadata": { + "editable": true, + "slideshow": { + "slide_type": "notes" + }, + "tags": [] + }, + "source": [ + "Speaker Notes:\n", + "\n", + "We can omit the brackets here (for the first example)." + ] + }, { "cell_type": "code", "execution_count": null, From 2a6b5442ff4021cda65fbaa2fe4d28c4e118c359 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 18 May 2026 12:05:30 +0100 Subject: [PATCH 2/3] Split tuple creation slide cells --- Intermediate.ipynb | 19 ++++++++++++++++--- Intermediate_full.ipynb | 19 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/Intermediate.ipynb b/Intermediate.ipynb index c3b1f19..09e80db 100644 --- a/Intermediate.ipynb +++ b/Intermediate.ipynb @@ -2300,8 +2300,21 @@ }, "outputs": [], "source": [ - "# Initialising a tuple with values\n", - "\n", + "# Initialising a tuple with values\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e873494-6a43-4402-beee-5bc2d507f33a", + "metadata": { + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + } + }, + "outputs": [], + "source": [ "# Initialising a tuple with one value\n" ] }, @@ -2379,7 +2392,7 @@ }, { "cell_type": "markdown", - "id": "812d5a14", + "id": "9380a5f8", "metadata": { "slideshow": { "slide_type": "fragment" diff --git a/Intermediate_full.ipynb b/Intermediate_full.ipynb index 2e3494f..b81fb9b 100644 --- a/Intermediate_full.ipynb +++ b/Intermediate_full.ipynb @@ -2244,8 +2244,21 @@ "source": [ "# Initialising a tuple with values\n", "my_tuple = (1,2,3)\n", - "print(my_tuple)\n", - "\n", + "print(my_tuple)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7e873494-6a43-4402-beee-5bc2d507f33a", + "metadata": { + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + } + }, + "outputs": [], + "source": [ "# Initialising a tuple with one value\n", "my_tuple = (1,)\n", "print(my_tuple)" @@ -2352,7 +2365,7 @@ }, { "cell_type": "markdown", - "id": "812d5a14", + "id": "9380a5f8", "metadata": { "slideshow": { "slide_type": "fragment" From f78c2999b0055af8586dd10a09e5fe6c573e071f Mon Sep 17 00:00:00 2001 From: Jordan Date: Tue, 19 May 2026 17:25:39 +0100 Subject: [PATCH 3/3] Separate tuple examples Splits both tuple examples into separate blocks --- Intermediate.ipynb | 19 +++++++++++++++++-- Intermediate_full.ipynb | 19 +++++++++++++++++-- 2 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Intermediate.ipynb b/Intermediate.ipynb index 09e80db..74fedd1 100644 --- a/Intermediate.ipynb +++ b/Intermediate.ipynb @@ -2346,8 +2346,23 @@ }, "outputs": [], "source": [ - "# The most basic example of tuple unpacking\n", - "\n", + "# The most basic example of tuple unpacking\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d2638ed7-4344-4297-b31b-bcdd649889c7", + "metadata": { + "editable": true, + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ "# You can use tuple unpacking when a function returns multiple values, or a tuple!\n" ] }, diff --git a/Intermediate_full.ipynb b/Intermediate_full.ipynb index b81fb9b..70f4750 100644 --- a/Intermediate_full.ipynb +++ b/Intermediate_full.ipynb @@ -2294,8 +2294,23 @@ "source": [ "# The most basic example of tuple unpacking\n", "a, b = 1, 2\n", - "print(a)\n", - "\n", + "print(a)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d2638ed7-4344-4297-b31b-bcdd649889c7", + "metadata": { + "editable": true, + "remove_code": "non-comments", + "slideshow": { + "slide_type": "" + }, + "tags": [] + }, + "outputs": [], + "source": [ "# You can use tuple unpacking when a function returns multiple values, or a tuple!\n", "def get_full_name():\n", " return \"First\", \"Last\"\n",