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
82 changes: 73 additions & 9 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,44 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{456.2, 789.2, 1254.9}\n",
"4560.25\n",
"Pablo, who is 45 years old, and lives in Brunnestrs. 19A has 2059.95 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"\n",
"name = input(\"Enter your name: \")\n",
"age = int(input(\"Enter your age: \"))\n",
"address = input(\"Enter your address: \")\n",
"salary = float(input(\"Enter your salary: \"))\n",
"\n",
"expenses = set()\n",
"\n",
"for i in range(3):\n",
" expense = float(input(f\"Enter expense {i + 1} : \"))\n",
" expenses.add(round(expense, 1))\n",
"\n",
"print(expenses)\n",
"print(salary)\n",
"\n",
"if((salary - sum(expenses)) >= 500):\n",
" is_salary_good = True\n",
" remaining_salary = salary - sum(expenses)\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.\")\n",
"else:\n",
" is_salary_good = False\n",
" remaining_salary = salary - sum(expenses)\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.\")\n"
]
},
{
Expand Down Expand Up @@ -85,7 +118,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,17 +135,48 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"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",
"242\n",
"python is awesome! some say the world will end in fire, some say in ice from what i’ve 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\n",
"261\n",
"['python', 'is', 'awesome!', 'some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire,', 'some', 'say', 'in', 'ice', 'from', 'what', 'i’ve', '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']\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"poem = (poem.strip().replace(\".\", \"\")).lower()\n",
"print(poem)\n",
"print(len(poem))\n",
"\n",
"combined = \"python is awesome! \" + \" \".join(poem.split())\n",
"\n",
"print(combined)\n",
"print(len(combined))\n",
"\n",
"poem_list = combined.split()\n",
"print(poem_list)\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +190,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.6"
}
},
"nbformat": 4,
Expand Down