From 1c3dd4a76107f88df95ac9365b444f2ccd2dad63 Mon Sep 17 00:00:00 2001 From: Edosa Erhunmwunse Date: Thu, 9 Oct 2025 18:42:50 +0200 Subject: [PATCH] extra data types assignment --- cfu-data-types.ipynb | 124 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 117 insertions(+), 7 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..66a33ba 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,49 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter your name: edosa\n", + "Enter your age: 37\n", + "Enter your address: wijngaardplein 2\n", + "Enter your salary: 3000\n", + "Enter your monthly expenses: 2000\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "edosa, who is 37years old, and lives in wijngaardplein 2 has 1000.0dollars left from her salary after expenses. it is True that she has more than $500 left\n" + ] + } + ], "source": [ - "# Your code here\n" + "list_info=[\"name\", \"age\", \"address\", \"salary\", \"expenses\"]\n", + "user_info={}\n", + "for i in list_info:\n", + " if i==\"name\":\n", + " user_info[i]=input(\"Enter your name: \")\n", + " elif i==\"age\":\n", + " user_info[i]=int(input(\"Enter your age: \"))\n", + " elif i==\"address\":\n", + " user_info[i]=input(\"Enter your address: \")\n", + " elif i==\"salary\":\n", + " user_info[i]=float(input(\"Enter your salary: \"))\n", + " else:\n", + " user_info[i]=float(input(\"Enter your expenses: \"))\n", + "user_info\n", + "remaining_salary= float(round((user_info[\"salary\"]-user_info[\"expenses\"]),1))\n", + "sufficient_funds=remaining_salary>=500\n", + "if sufficient_funds:\n", + " print(f\"{user_info[\"name\"]}, who is {user_info[age]}years old, and lives in {user_info[\"address\"]} has {remaining_salary}dollars left from her salary after expenses. it is {sufficient_funds} that she has more than $500 left\")\n", + "else:\n", + " print(f\"oops!!! You have about ${remaining_salary} which is insufficient for you\")\n" ] }, { @@ -85,7 +123,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 17, "metadata": {}, "outputs": [], "source": [ @@ -102,11 +140,83 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 37, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "import string\n", + "changer = str.maketrans(\" \",\" \",string.punctuation)\n", + "poem_1 = poem.translate(changer).lower()\n", + "poem_2=\"Python is awesome\"\n", + "new_string= poem_1 + \" \" + poem_2\n", + "new_string\n", + "len(new_string)\n", + "final_string=new_string.split(\" \")" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['some',\n", + " 'say',\n", + " 'the',\n", + " 'world',\n", + " 'will',\n", + " 'end',\n", + " 'in',\n", + " 'fire\\nsome',\n", + " 'say',\n", + " 'in',\n", + " 'ice\\nfrom',\n", + " 'what',\n", + " 'i’ve',\n", + " 'tasted',\n", + " 'of',\n", + " 'desire\\ni',\n", + " 'hold',\n", + " 'with',\n", + " 'those',\n", + " 'who',\n", + " 'favor',\n", + " 'fire\\nbut',\n", + " 'if',\n", + " 'it',\n", + " 'had',\n", + " 'to',\n", + " 'perish',\n", + " 'twice\\ni',\n", + " 'think',\n", + " 'i',\n", + " 'know',\n", + " 'enough',\n", + " 'of',\n", + " 'hate\\nto',\n", + " 'say',\n", + " 'that',\n", + " 'for',\n", + " 'destruction',\n", + " 'ice\\nis',\n", + " 'also',\n", + " 'great\\nand',\n", + " 'would',\n", + " 'suffice',\n", + " 'Python',\n", + " 'is',\n", + " 'awesome']" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "final_string\n" ] } ], @@ -126,7 +236,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.7" } }, "nbformat": 4,