From fdbdb200ecd95f3d0699038461ecd87b96d0bdf4 Mon Sep 17 00:00:00 2001 From: Ana Preto Date: Fri, 8 May 2026 13:52:22 +0100 Subject: [PATCH] exercises done --- cfu-data-types.ipynb | 57 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..f9b23b9 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Rita, who is 41 years old, and lives in Alhandra, Portugal has 93.42 dollars left from her salary after expenses. It is False that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "name = input(\"What is your name? \")\n", + "age = int(input(\"How old are you? \"))\n", + "address = input(\"Where do you live? \")\n", + "salary = float(input(\"What is your salary? \"))\n", + "expenses = float(input(\"What are your monthly expenses? \"))\n", + "\n", + "How_much_money_left = salary - expenses\n", + "remaining_salary = round(How_much_money_left, 2)\n", + "\n", + "is_salary_good = remaining_salary >= 500\n", + "\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 +104,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +121,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "import re\n" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "257\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" + ] + } + ], + "source": [ + "# Without punctuation, in lowercase and with \"Python is awesome\"\n", + "new_poem = re.sub(r'[^\\w\\s]', '', poem).lower() + \" \" +\"Python is awesome\"\n", + "print(len(new_poem))\n", + "poem_list = new_poem.split()\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +167,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,