diff --git a/your-code/main.ipynb b/your-code/main.ipynb index 01257d4..5348837 100755 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -31,7 +31,8 @@ " Output: the transformed list\n", " \"\"\"\n", " \n", - " # your code here\n", + " for i in lst:\n", + " return list(map(lmbda, lst))\n", " " ] }, @@ -46,11 +47,23 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 2, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(c)>" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# your code here" + "# your code here\n", + "lambda c: c + 273.15" ] }, { @@ -62,13 +75,25 @@ }, { "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" + "# your code here\n", + "\n", + "temps_kelvin = list(map(lambda c: c + 273.15, temps))\n", + "\n", + "print(temps_kelvin)" ] }, { @@ -82,11 +107,12 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "mod = lambda x,y: 1 if x%y == 0 else 0\n", + " " ] }, { @@ -100,7 +126,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -110,8 +136,7 @@ " 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: (x,b)\n" ] }, { @@ -123,11 +148,11 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ - "# your code here" + "divisible5 = divisor(5)" ] }, { @@ -139,18 +164,40 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(10, 5)" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "divisible5(10)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(8, 5)" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "divisible5(8)" ] @@ -168,20 +215,9 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[(1,), (2,), (3,), (4,), (5,)]" - ] - }, - "execution_count": 10, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# Here is an example of passing one list to the zip function. \n", "# Since the zip function returns an iterator, we need to evaluate the iterator by using a list comprehension.\n", @@ -199,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -222,7 +258,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -243,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -269,7 +305,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.8.5" } }, "nbformat": 4,