From f29322ef9d1695a715914812026e46b9d3be5a54 Mon Sep 17 00:00:00 2001 From: Stereo-Alex Date: Sat, 16 Jan 2021 12:58:50 +0100 Subject: [PATCH] final version --- your-code/main.ipynb | 126 +++++++++++++++++++++++++++++++++---------- 1 file changed, 97 insertions(+), 29 deletions(-) diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 01257d4..0a37f1d 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -23,16 +23,29 @@ "cell_type": "code", "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + ".(x)>" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "def modify_list(lst, lmbda):\n", " \"\"\"\n", " Input: list and lambda expression\n", " Output: the transformed list\n", " \"\"\"\n", - " \n", - " # your code here\n", - " " + " for item in lst: \n", + " lmbda = lambda x: x + 1\n", + " return lmbda\n", + "\n", + "modify_list([1,2,3,4,5], 2) " ] }, { @@ -46,11 +59,21 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 20, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "274.15\n" + ] + } + ], "source": [ - "# your code here" + "turn_to_kelvin = lambda x: (x + 273.15)\n", + "\n", + "print(turn_to_kelvin(1))" ] }, { @@ -62,13 +85,28 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[285.15, 296.15, 311.15, 218.14999999999998, 297.15]\n" + ] + } + ], "source": [ "temps = [12, 23, 38, -55, 24]\n", "\n", - "# your code here" + "turn_to_kelvin = lambda x: (x + 273.15)\n", + "\n", + "turn_to_kelvin_1 = []\n", + "\n", + "for temp in temps:\n", + " turn_to_kelvin_1.append(turn_to_kelvin((temp)))\n", + "\n", + "print(turn_to_kelvin_1)" ] }, { @@ -82,11 +120,25 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "mod = lambda x, y: int(x % y == 0)\n", + "\n", + "\n", + "mod(100, 2)" ] }, { @@ -100,18 +152,12 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "def divisor(b):\n", - " \"\"\"\n", - " Input: a number\n", - " Output: a function that returns 1 if the number is \n", - " divisible by another number (to be passed later) and zero otherwise.\n", - " \"\"\"\n", - " \n", - " # your code here" + " return lambda x: mod(x, b)" ] }, { @@ -123,11 +169,11 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "divisible5 = divisor(5)" ] }, { @@ -139,18 +185,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "1" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "divisible5(10)" + "divisible5(10)\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "0" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "divisible5(8)" ] @@ -269,7 +337,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.9.0" } }, "nbformat": 4,