From 1a6d3e31d23b89ed25b136cc3888d0d2db3ed0a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 18:37:32 +0200 Subject: [PATCH 1/4] Update cfu-data-types.ipynb Solve test --- cfu-data-types.ipynb | 56 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..95e0bb9 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "awfa, who is 34 years old, and lives in segs has 107819.0 dollars left from her salary after expesnes. it is True that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "info = [\"name\", \"age\", \"address\", \"salary\", \"expenses\"]\n", + "dict_info = {}\n", + "for var in info:\n", + " user_info = input(f\"Enter your {var}: \")\n", + " dict_info[var] = user_info\n", + "\n", + "for key,value in dict_info.items():\n", + " if key in (\"salary\", \"expenses\"):\n", + " dict_info[key] = float(value)\n", + " elif key in (\"age\"):\n", + " dict_info[key] = int(value)\n", + "\n", + "remaining_salary = dict_info[\"salary\"] - dict_info[\"expenses\"] \n", + "is_salary_good = remaining_salary >= 500\n", + "\n", + "print (f\"{dict_info[\"name\"]}, who is {dict_info[\"age\"]} years old, and lives in {dict_info[\"address\"]} has {remaining_salary} dollars left from her salary after expesnes. it is {is_salary_good} that she has more than $500 left.\")\n" ] }, { @@ -85,9 +108,17 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 39, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'i’ve', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', 'python', 'is', 'awesome']\n" + ] + } + ], "source": [ "poem = \"\"\"Some say the world will end in fire,\n", "Some say in ice.\n", @@ -97,7 +128,16 @@ "I think I know enough of hate\n", "To say that for destruction ice\n", "Is also great\n", - "And would suffice.\"\"\"" + "And would suffice.\"\"\"\n", + "\n", + "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").lower()\n", + "new_poem = poem_without_pnctuation + \"\\n\" + \"python is awesome\"\n", + "# print (new_poem)\n", + "# print (len(new_poem))\n", + "poem_list = new_poem.split()\n", + "\n", + "print (poem_list)\n", + "\n" ] }, { @@ -112,7 +152,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "venv-bootcamp (3.14.3)", "language": "python", "name": "python3" }, @@ -126,7 +166,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4, From bbcffd69da24b1208f787c2d5a5e3b5983565590 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 18:59:22 +0200 Subject: [PATCH 2/4] Update cfu-data-types.ipynb Improve code readability and structure --- cfu-data-types.ipynb | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index 95e0bb9..3339a09 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,14 +49,15 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "awfa, who is 34 years old, and lives in segs has 107819.0 dollars left from her salary after expesnes. it is True that she has more than $500 left.\n" + "{'name': 'Alberto', 'age': 38, 'address': 'avenida', 'salary': 34523.3, 'expenses': 3423.0}\n", + "Alberto, who is 38 years old, and lives in avenida has 31100 dollars left from her salary after expenses. It is True that she has more than $500 left.\n" ] } ], @@ -68,15 +69,17 @@ " dict_info[var] = user_info\n", "\n", "for key,value in dict_info.items():\n", - " if key in (\"salary\", \"expenses\"):\n", + " if key in (\"salary\",\"expenses\"):\n", " dict_info[key] = float(value)\n", - " elif key in (\"age\"):\n", + " elif key == \"age\":\n", " dict_info[key] = int(value)\n", "\n", - "remaining_salary = dict_info[\"salary\"] - dict_info[\"expenses\"] \n", + "print (dict_info)\n", + "\n", + "remaining_salary = round(dict_info[\"salary\"] - dict_info[\"expenses\"]) \n", "is_salary_good = remaining_salary >= 500\n", "\n", - "print (f\"{dict_info[\"name\"]}, who is {dict_info[\"age\"]} years old, and lives in {dict_info[\"address\"]} has {remaining_salary} dollars left from her salary after expesnes. it is {is_salary_good} that she has more than $500 left.\")\n" + "print (f'{dict_info[\"name\"]}, who is {dict_info[\"age\"]} years old, and lives in {dict_info[\"address\"]} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.')\n" ] }, { @@ -108,14 +111,24 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 47, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'i’ve', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', 'python', 'is', 'awesome']\n" + "some say the world will end in fire\n", + "some say in ice\n", + "from what i’ve tasted of desire\n", + "i hold with those who favor fire\n", + "but if it had to perish twice\n", + "i think i know enough of hate\n", + "to say that for destruction ice\n", + "is also great\n", + "and would suffice python is awesome!\n", + "259\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'i’ve', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'suffice', 'python', 'is', 'awesome!']\n" ] } ], @@ -130,11 +143,11 @@ "Is also great\n", "And would suffice.\"\"\"\n", "\n", - "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").lower()\n", - "new_poem = poem_without_pnctuation + \"\\n\" + \"python is awesome\"\n", - "# print (new_poem)\n", - "# print (len(new_poem))\n", - "poem_list = new_poem.split()\n", + "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"´\",\"\").lower()\n", + "new_poem = poem_without_pnctuation + \" \" + \"python is awesome!\"\n", + "print (new_poem)\n", + "print (len(new_poem))\n", + "poem_list = new_poem.split(\" \")\n", "\n", "print (poem_list)\n", "\n" From 0baa49424acc81fa5ebf625cf2a3493b5e9550cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 19:23:56 +0200 Subject: [PATCH 3/4] Update cfu-data-types.ipynb round remaining_salary to one decimal place --- cfu-data-types.ipynb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index 3339a09..8319c7b 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,15 +49,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 51, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'name': 'Alberto', 'age': 38, 'address': 'avenida', 'salary': 34523.3, 'expenses': 3423.0}\n", - "Alberto, who is 38 years old, and lives in avenida has 31100 dollars left from her salary after expenses. It is True that she has more than $500 left.\n" + "Elsa, who is 38 years old, and lives in Avenida has 12553299.8 dollars left from her salary after expenses. It is True that she has more than $500 left.\n" ] } ], @@ -74,9 +73,7 @@ " elif key == \"age\":\n", " dict_info[key] = int(value)\n", "\n", - "print (dict_info)\n", - "\n", - "remaining_salary = round(dict_info[\"salary\"] - dict_info[\"expenses\"]) \n", + "remaining_salary = round(dict_info[\"salary\"] - dict_info[\"expenses\"],1)\n", "is_salary_good = remaining_salary >= 500\n", "\n", "print (f'{dict_info[\"name\"]}, who is {dict_info[\"age\"]} years old, and lives in {dict_info[\"address\"]} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.')\n" @@ -111,7 +108,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 54, "metadata": {}, "outputs": [ { @@ -120,15 +117,15 @@ "text": [ "some say the world will end in fire\n", "some say in ice\n", - "from what i’ve tasted of desire\n", + "from what ive tasted of desire\n", "i hold with those who favor fire\n", "but if it had to perish twice\n", "i think i know enough of hate\n", "to say that for destruction ice\n", "is also great\n", "and would suffice python is awesome!\n", - "259\n", - "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'i’ve', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'suffice', 'python', 'is', 'awesome!']\n" + "258\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'ive', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'suffice', 'python', 'is', 'awesome!']\n" ] } ], @@ -143,7 +140,7 @@ "Is also great\n", "And would suffice.\"\"\"\n", "\n", - "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"´\",\"\").lower()\n", + "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").lower()\n", "new_poem = poem_without_pnctuation + \" \" + \"python is awesome!\"\n", "print (new_poem)\n", "print (len(new_poem))\n", From c4a565a1e314228a88e1848f3a57a698191c4a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 19:34:16 +0200 Subject: [PATCH 4/4] Update cfu-data-types.ipynb replace new lines for whitespaces in exercise 2 --- cfu-data-types.ipynb | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index 8319c7b..511e3ce 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -108,24 +108,16 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 55, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "some say the world will end in fire\n", - "some say in ice\n", - "from what ive tasted of desire\n", - "i hold with those who favor fire\n", - "but if it had to perish twice\n", - "i think i know enough of hate\n", - "to say that for destruction ice\n", - "is also great\n", - "and would suffice python is awesome!\n", + "some say the world will end in fire some say in ice from what ive tasted of desire i hold with those who favor fire but if it had to perish twice i think i know enough of hate to say that for destruction ice is also great and would suffice python is awesome!\n", "258\n", - "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'ive', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'suffice', 'python', 'is', 'awesome!']\n" + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', 'python', 'is', 'awesome!']\n" ] } ], @@ -140,7 +132,7 @@ "Is also great\n", "And would suffice.\"\"\"\n", "\n", - "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").lower()\n", + "poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").replace(\"\\n\",\" \").lower()\n", "new_poem = poem_without_pnctuation + \" \" + \"python is awesome!\"\n", "print (new_poem)\n", "print (len(new_poem))\n",