diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..e96ea9d 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -53,7 +53,22 @@ "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "# prompt the user to enter their personal information such as name, age, address, salary, and expenses\n", + "name = input('Enter your name: ')\n", + "age = int(input('Enter your age as a number: '))\n", + "address = input('Enter your address: ')\n", + "salary = float(input('Enter your yearly salary: '))\n", + "expenses = float(input('Enter your yearly expenses: '))\n", + "\n", + "# calculate to determine how much money they have left after expenses\n", + "savings = salary - expenses\n", + "round(savings, 1) # round the remaining money to one decimal. \n", + "\n", + "# Use a boolean variable to indicate whether the remaining salary is greater than or equal to 500.\n", + "if savings >= 500:\n", + " print(f'{name}, who is {age} years old, and lives in {address} has ${savings} left from their salary after expenses. It is good that they have more than $500 left.')\n", + "else:\n", + " print(f\"{name}, who is {age} years old, and lives in {address} has ${savings} left from their salary after expenses. It is sad that they don't have more than $500 left.\")\n" ] }, { @@ -85,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -97,22 +112,37 @@ "I think I know enough of hate\n", "To say that for destruction ice\n", "Is also great\n", - "And would suffice.\"\"\"" + "And would suffice.\"\"\"\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 12, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Length: 258\n", + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire\\nsome', 'say', 'in', 'ice\\nfrom', 'what', 'i’ve', '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" + "# Takes text from the variable `poem`, removes the punctuation and leaves everything in lowercase. \n", + "import string\n", + "no_punct = poem.lower().translate(str.maketrans('','', string.punctuation))\n", + "concat_str = no_punct + 'python is awesome!'\n", + "print(f'Length: {len(concat_str)}')\n", + "poem_list = concat_str.split(' ')\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +156,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,