From 0fc8c23ec5c7aee7fe7d6efda09e52b8115af27e Mon Sep 17 00:00:00 2001 From: Abanoub Barayo <62501003+abanoubdev@users.noreply.github.com> Date: Thu, 2 Apr 2026 10:05:15 +0200 Subject: [PATCH] Solved Lab --- cfu-data-types.ipynb | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..241ed2e 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -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" ] }, { @@ -85,7 +99,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -112,7 +126,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -126,7 +140,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4,