From 9fb8db5d4991ca81775cd7bc550966ad34cf9c78 Mon Sep 17 00:00:00 2001 From: JesusB11 Date: Wed, 18 Jun 2025 10:31:00 +0200 Subject: [PATCH] "resolution of extra lab" --- 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..dbe46f9 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -51,9 +51,45 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'name': 'Eva', 'age': 36, 'address': 'Caracas', 'salary': 32000.0, 'expenses': 30000.0}\n", + "Eva who is 36 years old and lives in Caracas has $2,000.0 left from her salary after expenses.\n", + " It is True that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "personal_information = {'name': '', 'age' : 0, 'address' : '', 'salary': 0.0, 'expenses' : 0.0}\n", + "\n", + "for item in personal_information:\n", + " if item == 'name':\n", + " personal_information[item] = input('Enter your name: ')\n", + " elif item == 'age':\n", + " personal_information[item] = int(input('Enter your age: '))\n", + " elif item == 'address':\n", + " personal_information[item] = input('Enter your address: ')\n", + " elif item == 'salary':\n", + " personal_information[item] = float(input('Enter your salary: '))\n", + " elif item == 'expenses':\n", + " personal_information[item] = float(input('Enter your expenses: '))\n", + "print(personal_information)\n", + "\n", + "remaining_salary= personal_information['salary'] - personal_information['expenses']\n", + "\n", + "if remaining_salary >= 500:\n", + " survivor= True\n", + "# print(\"Yes, you can live on this salary\")\n", + "else:\n", + " survivor = False\n", + "# print(\"You may need a second job\")\n", + "\n", + "# print(personal_information['name'], \"who is\", personal_information['age'], \"old and lives in \", personal_information['address'], \"has\", remaining_salary, \"leftfrom her salary after expenses. It is\", survivor, \"that she has more than $500 left.\")\n", + "print(f\"{personal_information['name']} who is {personal_information['age']} years old and lives in {personal_information['address']} has ${remaining_salary:,.1f} left from her salary after expenses.\\nIt is {survivor} that she has more than $500 left.\")" ] }, { @@ -85,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +138,35 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "251\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'firesome', 'say', 'in', 'icefrom', 'what', 'i’ve', 'tasted', 'of', 'desirei', 'hold', 'with', 'those', 'who', 'favor', 'firebut', 'if', 'it', 'had', 'to', 'perish', 'twicei', 'think', 'i', 'know', 'enough', 'of', 'hateto', 'say', 'that', 'for', 'destruction', 'iceis', 'also', 'greatand', 'would', 'suffice', 'python', 'is', 'awesome!']\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "poem_no_puntuation = poem.replace(',', '').replace('.', '').replace('\"',\"\").replace('\\n',\"\")\n", + "poem_lower= poem_no_puntuation.lower()\n", + "second_string= 'python is awesome!'\n", + "# print(poem_lower)\n", + "new_poem = poem_lower + ' ' + second_string\n", + "print(len(new_poem))\n", + "\n", + "poem_list = new_poem.split(\" \")\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -126,7 +180,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.3" } }, "nbformat": 4,