From b4a35a85f1e2a08641ba7c6522795589cdd4b4c3 Mon Sep 17 00:00:00 2001 From: luispabloaiello-da Date: Tue, 2 Sep 2025 14:58:13 +0200 Subject: [PATCH 1/2] Exercise poem --- cfu-data-types.ipynb | 82 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 73 insertions(+), 9 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..fba298b 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{456.2, 789.2, 1254.9}\n", + "4560.25\n", + "Pablo, who is 45 years old, and lives in Brunnestrs. 19A has 2059.95 dollars left from her salary after expenses. It is True that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "\n", + "name = input(\"Enter your name: \")\n", + "age = int(input(\"Enter your age: \"))\n", + "address = input(\"Enter your address: \")\n", + "salary = float(input(\"Enter your salary: \"))\n", + "\n", + "expenses = set()\n", + "\n", + "for i in range(3):\n", + " expense = float(input(f\"Enter expense {i + 1} : \"))\n", + " expenses.add(round(expense, 1))\n", + "\n", + "print(expenses)\n", + "print(salary)\n", + "\n", + "if((salary - sum(expenses)) >= 500):\n", + " is_salary_good = True\n", + " remaining_salary = salary - sum(expenses)\n", + " print(f\"{name}, who is {age} years old, and lives in {address} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.\")\n", + "else:\n", + " is_salary_good = False\n", + " remaining_salary = salary - sum(expenses)\n", + " print(f\"{name}, who is {age} years old, and lives in {address} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.\")\n" ] }, { @@ -85,7 +118,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +135,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 24, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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\n", + "242\n", + "python is awesome! 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\n", + "261\n", + "['python', 'is', 'awesome!', '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']\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "poem = (poem.strip().replace(\".\", \"\")).lower()\n", + "print(poem)\n", + "print(len(poem))\n", + "\n", + "combined = \"python is awesome! \" + \" \".join(poem.split())\n", + "\n", + "print(combined)\n", + "print(len(combined))\n", + "\n", + "poem_list = combined.split()\n", + "print(poem_list)\n" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -126,7 +190,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.6" } }, "nbformat": 4, From 954244e76aa79f704ad4945b7cdccba9cdf23772 Mon Sep 17 00:00:00 2001 From: luispabloaiello-da Date: Tue, 2 Sep 2025 15:00:15 +0200 Subject: [PATCH 2/2] Exercise 1 and 2 completed --- cfu-data-types.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index fba298b..2ad5d3e 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -135,7 +135,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 25, "metadata": {}, "outputs": [ {