From c27b33808797f763f4021901cf33e1502ed4e2a0 Mon Sep 17 00:00:00 2001 From: Teresa Mendes Coelho Date: Thu, 20 Aug 2026 22:59:09 +0100 Subject: [PATCH] Solved lab --- cfu-data-types.ipynb | 81 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 72 insertions(+), 9 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..3b39c27 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Teresa, who is 36 years old, and lives in lisboa has 700.0 dollars left from her salary after expenses. It is True 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(\"What is your address? \")\n", + "salary = float(input(\"What is your salary? \"))\n", + "expenses = float(input(\"How much are your expenses? \"))\n", + "\n", + "remaining_salary = round(salary - expenses, 1)\n", + "\n", + "is_salary_good = remaining_salary >= 500\n", + "\n", + "print(\n", + " f\"{name}, who is {age} years old, and lives in {address} \"\n", + " f\"has {remaining_salary} dollars left from her salary after expenses. \"\n", + " f\"It is {is_salary_good} that she has more than $500 left.\"\n", + ")\n" ] }, { @@ -85,7 +107,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +124,58 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "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" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "import string\n", + "\n", + "poem_clean = poem.translate(str.maketrans(\"\", \"\", string.punctuation)).lower()\n", + "\n", + "new_string = poem_clean + \" python is awesome!\"\n", + "\n", + "print(len(new_string))\n", + "\n", + "poem_list = new_string.split(\" \")\n", + "\n", + "print(poem_list)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -126,7 +189,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4,