diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..9bbe86f 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -53,7 +53,59 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "name = input(\"Enter your name: \")\n", + "age = input(\"Enter your age: \")\n", + "address = input(\"Enter your address: \")\n", + "salary = input(\"Enter your salary: \")\n", + "expenses = input(\"Enter your expenses: \")\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "age = int(age)\n", + "salary = float(salary)\n", + "expenses = float(expenses)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "remaining_salary = salary - expenses\n", + "remaining_salary = round(remaining_salary, 1)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [], + "source": [ + "is_salary_good = remaining_salary >= 500" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "manuel, who is 35 years old, and lives in españa has 8000.0 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 +137,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +154,73 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "clean_poem = poem.lower()\n" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [], + "source": [ + "clean_poem = clean_poem.replace(\",\", \"\")\n", + "clean_poem = clean_poem.replace(\".\", \"\")\n", + "clean_poem = clean_poem.replace(\"'\", \"\")\n", + "clean_poem = clean_poem.replace(\"\\n\", \" \")" + ] + }, + { + "cell_type": "code", + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "new_text = clean_poem + \" python is awesome!\"" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "259\n" + ] + } + ], + "source": [ + "print(len(new_text))" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['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": [ + "poem_list = new_text.split(\" \")\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +234,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,