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
135 changes: 129 additions & 6 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,71 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"str"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n",
"\n",
"salary = input(\"input your salary: \")\n",
"name = input(\"input your name: \")\n",
"age = input(\"input your age: \")\n",
"address = input(\"input your address: \")\n",
"expenses = input(\"input your expenses: \")\n"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"salary = int(salary)\n",
"age = int(age)\n",
"expenses = int(expenses)\n",
"\n",
"remaining_salary = salary - expenses"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"def good_salary(salary, remaining_salary):\n",
" if remaining_salary >= 500:\n",
" return \"good\"\n",
" else:\n",
" return \"bad\"\n",
" \n",
"is_salary_good = good_salary(salary, remaining_salary)\n"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"isis, who is 38 years old, and lives in street has 300 dollars left from her salary after expenses. It is bad that she has more than $500 left.\n"
]
}
],
"source": [
"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 @@ -85,7 +147,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -100,19 +162,80 @@
"And would suffice.\"\"\""
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'some say the world will end in fire some say in ice from what ive tasted of desire i hold with those who favor fire but if it had to perish twice i think i know enough of hate to say that for destruction ice is also great and would suffice'"
]
},
"execution_count": 38,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Your code here\n",
"import re\n",
"clean = re.sub(r'[^\\w\\s]', '', poem)\n",
"\n",
"clean_poem = ' '.join(clean.splitlines()).lower()\n",
"\n",
"clean_poem"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'some say the world will end in fire some say in ice from what ive tasted of desire i hold with those who favor fire but if it had to perish twice i think i know enough of hate to say that for destruction ice is also great and would suffice python is awesome!'"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#create variable for new string and concatenate\n",
"new_string = \"python is awesome!\"\n",
"\n",
"combined = clean_poem + \" \" + new_string\n",
"\n",
"combined"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', 'python', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"poem_list = list(combined.split(\" \"))\n",
"\n",
"print(poem_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +249,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.9"
}
},
"nbformat": 4,
Expand Down