From 1e3d7d573bf2597329553a2a5f39191ccbfd6900 Mon Sep 17 00:00:00 2001 From: Julia Date: Tue, 2 Sep 2025 13:24:34 +0100 Subject: [PATCH] solved extra lab 1 --- cfu-data-types.ipynb | 70 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 62 insertions(+), 8 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..ea638c6 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,41 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Please insert your name: Julia\n", + "Please insert your age: 30\n", + "Please insert your address: R Lisbon\n", + "Please insert your salary: 600\n", + "Please insert your expenses: 200\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Julia, who is 30 years old, and lives in R Lisbon has 400.0 dollars left from her salary after expenses. It is False that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "name = input(\"Please insert your name: \")\n", + "age = input(\"Please insert your age: \")\n", + "address = input(\"Please insert your address: \")\n", + "salary = round(float(input(\"Please insert your salary: \")))\n", + "expenses = float(input(\"Please insert your expenses: \"))\n", + "remaining_salary = salary - expenses\n", + "if remaining_salary > 500:\n", + " is_salary_good = True\n", + "else:\n", + " is_salary_good = False\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 +115,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -102,12 +132,36 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "259\n", + "['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": [ - "# Your code here\n" + "# Your code here\n", + "first_format_poem = poem.replace(\",\", \"\")\n", + "first_format_poem2 = first_format_poem.replace(\".\", \"\")\n", + "format_poem = first_format_poem2.lower()\n", + "poem_add = \"python is awesome!\"\n", + "new_poem = format_poem + \" \" + poem_add\n", + "print(len(new_poem))\n", + "poem_list = new_poem.split( )\n", + "print(poem_list)" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -126,7 +180,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,