From dfa1a3e243576f88cfaa55a501c366243a04a73e Mon Sep 17 00:00:00 2001 From: Yue Zhou Date: Mon, 1 Sep 2025 11:23:09 +0200 Subject: [PATCH] solved lab --- cfu-data-types.ipynb | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..10ff372 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -53,7 +53,16 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "name = input(\"Please input your name:\")\n", + "age = int(input(\"Please input your age:\"))\n", + "address = input(\"Please input your address:\")\n", + "salary = float(input(\"Please input your salary:\"))\n", + "expenses = float(input(\"Please input your expenses:\"))\n", + "remaining = round(salary - expenses,1)\n", + "\n", + "is_salary_good = str(remaining >= 500).lower()\n", + "\n", + "print(f\"{name}, who is {age} years old, and lives in {address} has {remaining} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.\")" ] }, { @@ -85,7 +94,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -106,13 +115,38 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "import re\n", + "\n", + "cleaned_poem = re.sub(r'[^\\w\\s]','',poem).replace('\\n',' ')\n", + "\n", + "concated_string = cleaned_poem + ' Python is asesome!'\n", + "\n", + "concated_string" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(len(concated_string))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "concated_string_list = concated_string.split(' ')\n", + "concated_string_list" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "py310", "language": "python", "name": "python3" }, @@ -126,7 +160,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.18" } }, "nbformat": 4,