From 287f490d047a12c65bd99f181144ec313fa77b06 Mon Sep 17 00:00:00 2001 From: Ulrich <ulrich.kerzel@rwth-aachen.de> Date: Mon, 15 Apr 2024 16:28:54 +0200 Subject: [PATCH] add comments to account solution whre to improve more --- pythonintro/Classes.ipynb | 6 +++--- pythonintro/Classes_Inheritance.ipynb | 2 +- pythonintro/Classes_PrivateVariables.ipynb | 2 +- pythonintro/Functions.ipynb | 21 ++++++++++++------- .../solutions/Solution_AccountClass.ipynb | 1 + 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pythonintro/Classes.ipynb b/pythonintro/Classes.ipynb index 6500478..dcd8647 100644 --- a/pythonintro/Classes.ipynb +++ b/pythonintro/Classes.ipynb @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -69,7 +69,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -362,7 +362,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { diff --git a/pythonintro/Classes_Inheritance.ipynb b/pythonintro/Classes_Inheritance.ipynb index f7d0a9c..502a532 100644 --- a/pythonintro/Classes_Inheritance.ipynb +++ b/pythonintro/Classes_Inheritance.ipynb @@ -150,7 +150,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { diff --git a/pythonintro/Classes_PrivateVariables.ipynb b/pythonintro/Classes_PrivateVariables.ipynb index ef6439d..68dcc4e 100644 --- a/pythonintro/Classes_PrivateVariables.ipynb +++ b/pythonintro/Classes_PrivateVariables.ipynb @@ -169,7 +169,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { diff --git a/pythonintro/Functions.ipynb b/pythonintro/Functions.ipynb index 85deb0a..b3a0df7 100644 --- a/pythonintro/Functions.ipynb +++ b/pythonintro/Functions.ipynb @@ -84,23 +84,25 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The sum is: 7.1\n" + "<class 'int'> <class 'int'>\n", + "The sum is: 7 3 4\n" ] } ], "source": [ "def my_sum(x, y):\n", - " return x + y\n", + " print(type(x), type(y))\n", + " return x +y, x, y \n", "\n", - "sum = my_sum(3,4)\n", - "print('The sum is: {}'.format(sum))" + "sum, a ,b = my_sum(3,4)\n", + "print('The sum is: {} {} {}'.format(sum,a,b))" ] }, { @@ -505,13 +507,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "the Fibonacci number is: -3\n", + "the Fibonacci number is: -2\n", + "the Fibonacci number is: -1\n", "the Fibonacci number is: 0\n", "the Fibonacci number is: 1\n", "the Fibonacci number is: 1\n", @@ -528,7 +533,7 @@ "source": [ "Fibonacci = lambda n: n if n <= 1 else Fibonacci(n-1) + Fibonacci(n-2)\n", "\n", - "for i in range(0,10):\n", + "for i in range(-3,10):\n", " fib = Fibonacci(i)\n", " print('the Fibonacci number is: {}'.format(fib))\n" ] @@ -550,7 +555,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.6" + "version": "3.10.12" }, "orig_nbformat": 4, "vscode": { diff --git a/pythonintro/solutions/Solution_AccountClass.ipynb b/pythonintro/solutions/Solution_AccountClass.ipynb index 2849ad1..47fe7ea 100644 --- a/pythonintro/solutions/Solution_AccountClass.ipynb +++ b/pythonintro/solutions/Solution_AccountClass.ipynb @@ -42,6 +42,7 @@ "class Account():\n", " def __init__(self, name, balance = 0):\n", " self._name = name\n", + " # what can we improve in the following line?\n", " self._balance = int(balance)\n", " if self._balance < 0:\n", " self._balance = 0\n", -- GitLab