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
63 changes: 55 additions & 8 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Vincent, who is 31 years old, and lives in 123 backstreet has 500.0 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"name, age, address, salary, expenses = input(\"Please enter your name, age, address, salary and expenses (separated by commas:','): \").split(',')\n",
"age = int(age)\n",
"salary = float(salary)\n",
"expenses = float(expenses)\n",
"remaining_salary = round((salary - expenses), 1)\n",
"\n",
"is_salary_good = True\n",
"if remaining_salary < 500:\n",
" is_salary_good = False\n",
"\n",
"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.\")"
]
},
{
Expand Down Expand Up @@ -85,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -104,15 +122,44 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"249\n",
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'firesome', 'say', 'in', 'icefrom', 'what', 'ive', 'tasted', 'of', 'desirei', 'hold', 'with', 'those', 'who', 'favor', 'firebut', 'if', 'it', 'had', 'to', 'perish', 'twicei', 'think', 'i', 'know', 'enough', 'of', 'hateto', 'say', 'that', 'for', 'destruction', 'iceis', 'also', 'greatand', 'would', 'sufficepython', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"punctuation = [\".\",\";\",\",\",\"!\",\"?\",\":\",\"'\",\"...\",\"\\n\",\"’\"]\n",
"stripped_poem = \"\"\n",
"\n",
"for i in poem:\n",
" if i in punctuation:\n",
" continue\n",
" else:\n",
" stripped_poem += i.lower()\n",
"\n",
"new_poem = stripped_poem + \"python is awesome!\"\n",
"print(len(new_poem))\n",
"\n",
"poem_list = new_poem.split(\" \")\n",
"print(poem_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +173,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.9"
}
},
"nbformat": 4,
Expand Down