From 2a1ef8209b433fe18c812cf827f3eec015c467b1 Mon Sep 17 00:00:00 2001 From: Carla Fajula Date: Wed, 22 Jul 2026 11:11:44 +0200 Subject: [PATCH] Solved extra Lab --- cfu-data-types.ipynb | 181 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 172 insertions(+), 9 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..9d42565 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,55 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter your name: Carla\n", + "Enter your age: 23\n", + "Enter your adress: Les Preses\n", + "Enter your salary: 1000.5\n", + "Enter your expenses: 500\n" + ] + } + ], + "source": [ + "name = input(\"Enter your name: \")\n", + "age = int(input(\"Enter your age: \"))\n", + "address = input(\"Enter your adress: \")\n", + "salary = float(input(\"Enter your salary: \"))\n", + "expenses = float(input(\"Enter your expenses: \"))\n", + "\n", + "remaining_salary = round(salary - expenses, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "is_salary_good = remaining_salary >= 500" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Carla, who is 23 years old, and lives in Les Preses has 500.5 dollars left from her salary after expenses. It is True that she has more than $500 left.\n" + ] + } + ], + "source": [ + "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.\")" ] }, { @@ -85,7 +129,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 46, "metadata": {}, "outputs": [], "source": [ @@ -102,19 +146,138 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 47, "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" + ] + } + ], "source": [ - "# Your code here\n" + "lower = poem.lower()\n", + "new_poem = lower.replace(\",\",\"\")\n", + "new_poem = new_poem.replace(\".\",\"\")\n", + "print(new_poem)" ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The length of the new string is 259\n" + ] + } + ], + "source": [ + "joint_poem = new_poem + \" python is awesome!\"\n", + "length=len(joint_poem)\n", + "print(\"The length of the new string is\",length)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['some',\n", + " 'say',\n", + " 'the',\n", + " 'world',\n", + " 'will',\n", + " 'end',\n", + " 'in',\n", + " 'fire',\n", + " 'some',\n", + " 'say',\n", + " 'in',\n", + " 'ice',\n", + " 'from',\n", + " 'what',\n", + " 'i’ve',\n", + " 'tasted',\n", + " 'of',\n", + " 'desire',\n", + " 'i',\n", + " 'hold',\n", + " 'with',\n", + " 'those',\n", + " 'who',\n", + " 'favor',\n", + " 'fire',\n", + " 'but',\n", + " 'if',\n", + " 'it',\n", + " 'had',\n", + " 'to',\n", + " 'perish',\n", + " 'twice',\n", + " 'i',\n", + " 'think',\n", + " 'i',\n", + " 'know',\n", + " 'enough',\n", + " 'of',\n", + " 'hate',\n", + " 'to',\n", + " 'say',\n", + " 'that',\n", + " 'for',\n", + " 'destruction',\n", + " 'ice',\n", + " 'is',\n", + " 'also',\n", + " 'great',\n", + " 'and',\n", + " 'would',\n", + " 'suffice',\n", + " 'python',\n", + " 'is',\n", + " 'awesome!']" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "poem_list=joint_poem.split()\n", + "poem_list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python [conda env:base] *", "language": "python", - "name": "python3" + "name": "conda-base-py" }, "language_info": { "codemirror_mode": { @@ -126,7 +289,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,