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
58 changes: 50 additions & 8 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 51,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Elsa, who is 38 years old, and lives in Avenida has 12553299.8 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"info = [\"name\", \"age\", \"address\", \"salary\", \"expenses\"]\n",
"dict_info = {}\n",
"for var in info:\n",
" user_info = input(f\"Enter your {var}: \")\n",
" dict_info[var] = user_info\n",
"\n",
"for key,value in dict_info.items():\n",
" if key in (\"salary\",\"expenses\"):\n",
" dict_info[key] = float(value)\n",
" elif key == \"age\":\n",
" dict_info[key] = int(value)\n",
"\n",
"remaining_salary = round(dict_info[\"salary\"] - dict_info[\"expenses\"],1)\n",
"is_salary_good = remaining_salary >= 500\n",
"\n",
"print (f'{dict_info[\"name\"]}, who is {dict_info[\"age\"]} years old, and lives in {dict_info[\"address\"]} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.')\n"
]
},
{
Expand Down Expand Up @@ -85,9 +108,19 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 55,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"some say the world will end in fire some say in ice from what ive 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",
"258\n",
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', '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 = \"\"\"Some say the world will end in fire,\n",
"Some say in ice.\n",
Expand All @@ -97,7 +130,16 @@
"I think I know enough of hate\n",
"To say that for destruction ice\n",
"Is also great\n",
"And would suffice.\"\"\""
"And would suffice.\"\"\"\n",
"\n",
"poem_without_pnctuation = poem.replace(\".\",\"\").replace(\",\",\"\").replace(\"’\",\"\").replace(\"\\n\",\" \").lower()\n",
"new_poem = poem_without_pnctuation + \" \" + \"python is awesome!\"\n",
"print (new_poem)\n",
"print (len(new_poem))\n",
"poem_list = new_poem.split(\" \")\n",
"\n",
"print (poem_list)\n",
"\n"
]
},
{
Expand All @@ -112,7 +154,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "venv-bootcamp (3.14.3)",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +168,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.14.3"
}
},
"nbformat": 4,
Expand Down