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
71 changes: 48 additions & 23 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,53 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your name: egbe\n",
"Enter your age: 33\n",
"Enter your address: germany\n",
"Enter your monthly salary: 2800\n",
"Enter your monthly expenses: 1500\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"egbe, who is 33 years old, and lives in germany has 1300.0 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"# Step 1: Ask for user input\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 monthly salary: \"))\n",
"expenses = float(input(\"Enter your monthly expenses: \"))\n",
"\n",
"# Step 2: Calculate remaining salary\n",
"remaining_salary = round(salary - expenses, 1)\n",
"\n",
"# Step 3: Boolean check\n",
"is_salary_good = remaining_salary >= 500\n",
"\n",
"# Step 4: Final formatted output\n",
"message = (\n",
" f\"{name}, who is {age} years old, and lives in {address} has \"\n",
" f\"{remaining_salary} dollars left from her salary after expenses. \"\n",
" f\"It is {is_salary_good} that she has more than $500 left.\"\n",
")\n",
"\n",
"# Step 5: Print message\n",
"print(\"\\n\" + message)\n",
"\n"
]
},
{
Expand Down Expand Up @@ -83,23 +125,6 @@
"- *Use method chaining to simplify your code. If you are not sure what it is, read this tutorial before: https://pyneng.readthedocs.io/en/latest/book/04_data_structures/method_chaining.html*\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"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.\"\"\""
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -112,9 +137,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python [conda env:base] *",
"language": "python",
"name": "python3"
"name": "conda-base-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -126,7 +151,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down