From 69854fc3efd89d2ecac00a7c42750863a53e156b Mon Sep 17 00:00:00 2001 From: gfkpth Date: Sun, 11 May 2025 21:06:05 +0200 Subject: [PATCH] commit --- cfu-data-types.ipynb | 74 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 9 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..c01c90b 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -49,11 +49,54 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Joan, who is 37 years old, and lives in Hoppegarten, \n", + " has 1500.0 dollars left from her salary after expenses. \n", + " It is True that she has more than $500 left.\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "name = input('Please enter your name: ')\n", + "age = None\n", + "while not isinstance(age,int):\n", + " age = input('Please enter your age: ')\n", + " if age.isdigit():\n", + " age = int(age)\n", + "\n", + " \n", + "address = input('Please enter your address: ')\n", + "salary = None\n", + "while not isinstance(salary, float):\n", + " salary = input('Please enter your salary: ')\n", + " if salary.isdigit():\n", + " salary = float(salary) \n", + " \n", + "\n", + "expenses = None\n", + "while not isinstance(expenses,float):\n", + " expenses = input('Please enter your expenses: ')\n", + " if expenses.isdigit():\n", + " expenses = float(expenses) \n", + "\n", + "remaining = round(salary-expenses,1)\n", + "\n", + "if remaining >= 500:\n", + " over_500 = True\n", + "else:\n", + " over_500 = False\n", + " \n", + "print(f'''{name}, who is {age} years old, and lives in {address}, \n", + " has {remaining} dollars left from her salary after expenses. \n", + " It is {over_500} that she has more than $500 left.''')\n", + " \n" ] }, { @@ -85,7 +128,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +145,30 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "257\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'ive', 'tasted', 'of', 'desire\\ni', 'hold', 'with', 'those', 'who', 'favor', 'fire\\nbut', 'if', 'it', 'had', 'to', 'perish', 'twice\\ni', 'think', 'i', 'know', 'enough', 'of', 'hate\\nto', 'say', 'that', 'for', 'destruction', 'ice\\nis', 'also', 'great\\nand', 'would', 'sufficepython', 'is', 'awesome!']\n" + ] + } + ], "source": [ - "# Your code here\n" + "# Your code here\n", + "newstring = poem.replace(',','').replace('.','').replace('’','').lower() + 'python is awesome!'\n", + "print(len(newstring))\n", + "poem_list = newstring.split(' ')\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -126,7 +182,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.11" } }, "nbformat": 4,