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
22 changes: 18 additions & 4 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,21 @@
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"try:\n",
" name = input(\"What is your name? \")\n",
" age = int(input(\"What is your age? \"))\n",
" address = input(\"What is your address? \")\n",
" salary = float(input(\"What is your salary? \"))\n",
" expenses = float(input(\"What are your expenses? \"))\n",
" remaining_salary = salary - expenses\n",
" is_salary_good = remaining_salary > 500\n",
" str = f\"{name}, who is {age} years old, and live at {address}, has a remaining salary of {remaining_salary:.1f} after expenses. It is {'good' if is_salary_good else 'not good'} that she has more $500 left.\"\n",
" print(str)\n",
"except ValueError:\n",
" print(\"Please enter valid numbers for age, salary and expenses.\")\n",
"except Exception as e:\n",
" print(\"Caught an exception:\", e)\n"
]
},
{
Expand Down Expand Up @@ -85,7 +99,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -112,7 +126,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +140,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.14.3"
}
},
"nbformat": 4,
Expand Down