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
146 changes: 139 additions & 7 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,68 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your name: Jan\n",
"Enter your age: 39\n",
"Enter your address: Berlin\n",
"Enter your salary: 6000\n",
"Enter your total expenses: 4000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Jan, who is 39 years old, and lives in Berlin, has 2000.0 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"name = input(\"Enter your name: \")\n",
"\n",
"age = int(input(\"Enter your age: \"))\n",
"\n",
"address = input(\"Enter your address: \")\n",
"\n",
"salary = float(input(\"Enter your salary: \"))\n",
"\n",
"expenses = float(input(\"Enter your total expenses: \"))\n",
"\n",
"remaining_salary = salary - expenses\n",
"\n",
"remaining_salary = round(remaining_salary, 1)\n",
"\n",
"is_salary_good = remaining_salary >= 500\n",
"\n",
"print(\n",
" f\"{name}, who is {age} years old, and lives in {address}, \"\n",
" f\"has {remaining_salary} dollars left from her salary after expenses. \"\n",
" f\"It is {is_salary_good} that she has more than $500 left.\"\n",
")# Your code here\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"remaining_salary = salary - expenses"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"is_salary_good = remaining_salary >= 500"
]
},
{
Expand Down Expand Up @@ -85,7 +142,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,12 +159,87 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"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": [
"# Your code here\n"
"poem = \"\"\"Some say the world will end in fire,\n",
"Some say in ice.\n",
"From what I’ve tasted of desire\n",
"I hold with those who favor fire.\n",
"But if it had to perish twice,\n",
"I think I know enough of hate\n",
"To say that for destruction ice\n",
"Is also great\n",
"And would suffice.\"\"\"\n",
"\n",
"clean_poem = (\n",
" poem.lower()\n",
" .replace(\",\", \"\")\n",
" .replace(\".\", \"\")\n",
" .replace(\"’\", \"\")\n",
" .replace(\"\\n\", \" \")\n",
")\n",
"\n",
"new_poem = clean_poem + \" python is awesome!\"\n",
"\n",
"print(new_poem)\n",
"print(len(new_poem))\n",
"\n",
"poem_list = new_poem.split(\" \")\n",
"\n",
"print(poem_list)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"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": [
"clean_poem = (\n",
" poem\n",
" .lower()\n",
" .replace(\",\", \"\")\n",
" .replace(\".\", \"\")\n",
" .replace(\"’\", \"\")\n",
" .replace(\"\\n\", \" \")\n",
")\n",
"\n",
"new_poem = clean_poem + \" python is awesome!\"\n",
"\n",
"print(len(new_poem))\n",
"\n",
"poem_list = new_poem.split(\" \")\n",
"\n",
"print(poem_list)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -126,7 +258,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.14"
}
},
"nbformat": 4,
Expand Down