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
87 changes: 80 additions & 7 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,43 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your name: Thuong\n",
"Enter your age: 35\n",
"Enter your address: Paris\n",
"Enter your salary: 800\n",
"Enter your expenses: 180.7\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Thuong, who is 35 years old, and lives in Paris has 619.3 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"name = str(input(\"Enter your name: \"))\n",
"age = int(input(\"Enter your age: \"))\n",
"address = str(input(\"Enter your address: \"))\n",
"salary = float(input(\"Enter your salary: \"))\n",
"expenses = float(input(\"Enter your expenses: \"))\n",
"\n",
"remaining_salary = round(salary - expenses, 1)\n",
"\n",
"is_salary_good = False\n",
"if remaining_salary >= 500:\n",
" is_salary_good = True\n",
"\n",
"print(f\"{name}, who is {age} years old, and lives in {address} has {remaining_salary} dollars left from her salary after expenses. It is {is_salary_good} that she has more than $500 left.\")"
]
},
{
Expand Down Expand Up @@ -102,12 +134,53 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 23,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"thuong\n",
"Len of new string: 258\n"
]
},
{
"data": {
"text/plain": [
"'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 suffice'"
]
},
"execution_count": 23,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n"
"# Your code here\n",
"import string\n",
"#print(string.punctuation)\n",
"\n",
"print(''.join(['t','h','u','o','n','g']))\n",
"\n",
"clean_poem = ''.join([ch.lower() for ch in poem if ch not in string.punctuation])\n",
"new_poem = clean_poem + \"python is awesome!\"\n",
"print(\"Len of new string: \", len(new_poem))\n",
"poem_list = new_poem.split('')\n",
"clean_poem"
]
},
{
"cell_type": "raw",
"metadata": {},
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -126,7 +199,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.14.0"
}
},
"nbformat": 4,
Expand Down