diff --git a/Intermediate.ipynb b/Intermediate.ipynb index f9389fd..74fedd1 100644 --- a/Intermediate.ipynb +++ b/Intermediate.ipynb @@ -2300,11 +2300,72 @@ }, "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" ] }, + { + "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" + ] + }, + { + "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" + ] + }, { "cell_type": "code", "execution_count": null, @@ -2346,7 +2407,7 @@ }, { "cell_type": "markdown", - "id": "812d5a14", + "id": "9380a5f8", "metadata": { "slideshow": { "slide_type": "fragment" diff --git a/Intermediate_full.ipynb b/Intermediate_full.ipynb index a7ea66c..70f4750 100644 --- a/Intermediate_full.ipynb +++ b/Intermediate_full.ipynb @@ -2244,13 +2244,97 @@ "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)" ] }, + { + "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)" + ] + }, + { + "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", + "\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, @@ -2296,7 +2380,7 @@ }, { "cell_type": "markdown", - "id": "812d5a14", + "id": "9380a5f8", "metadata": { "slideshow": { "slide_type": "fragment"