From d675eff2e4caa665319f379f927e9a61dc37d47f Mon Sep 17 00:00:00 2001 From: Bright Jaato Date: Sun, 20 Sep 2026 02:33:05 +0200 Subject: [PATCH] feat: 20260920_Complete CFU data types extra exercises --- cfu-data-types.ipynb | 66 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..8dc12ae 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,13 +49,48 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Bd, who is 12 years old, and lives in Wekl has $1000.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", + "name = input(\"What is your name?: \").title() #request info from user and put it in a title form\n", + "age = int(input(\"How old are you?: \"))# age is casted from string to int\n", + "address = input(\"What is your address?: \").title()\n", + "salary = float(input(\"How much salary do you receive?: \"))# cast str type to float type\n", + "expenses = float(input(\"How much is your total expenses every month?: \"))\n", + "money_after_expenses = salary - expenses\n", + "\n", + "is_salary_good = money_after_expenses >= 500 # conditional statement\n", + "\n", + "print(f\"{name}, who is {age} years old, and lives in {address} has ${round(money_after_expenses, 1)} left from her salary after expenses.\")\n", + "print(f\"It is {is_salary_good} that she has more than $500 left.\")\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Bn, who is 5 years old, and lives in Gh has $1000.0 left from her salary after expenses. It is True that she has more than $500 left.\n" + ] + } + ], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -85,7 +120,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +137,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 49, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "276\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'ive', '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', 'sufficepython', 'is', 'awesome!', 'python', 'is', 'awesome!']\n" + ] + } + ], "source": [ - "# Your code here\n" + "poem = poem.replace(\".\", \"\").replace(\",\", \"\").replace(\"’\", \"\").lower() \n", + "new_poem = poem + \" python is awesome!\"\n", + "print(len(new_poem))\n", + "poem_list = new_poem.split(\" \")\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +174,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.7" } }, "nbformat": 4,