Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 117 additions & 7 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
},
{
Expand Down Expand Up @@ -85,7 +123,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -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"
]
}
],
Expand All @@ -126,7 +236,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down