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
111 changes: 101 additions & 10 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,41 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdin",
"output_type": "stream",
"text": [
"Enter your name: Ricardo\n",
"Enter your age: 38\n",
"Enter your address: Portugal\n",
"Enter your salary: 2000\n",
"Enter your expenses: 1000\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Ricardo, who is 38 years old, and lives in Portugal has 1000.0 dollars left from her salary after expenses. It is True that she has more than $500 left.\n"
]
}
],
"source": [
"# Your code here\n"
"name = input(\"Enter your name: \")\n",
"age = int(input(\"Enter your age: \"))\n",
"address = input(\"Enter your address: \")\n",
"salary = float(input(\"Enter your salary: \"))\n",
"expenses = float(input(\"Enter your expenses: \"))\n",
"\n",
"remaining_salary = (salary - expenses)\n",
"remaining_salary = round(remaining_salary, 1)\n",
"\n",
"is_salary_good = remaining_salary >= 500\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.\")\n"
]
},
{
Expand Down Expand Up @@ -85,7 +115,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,19 +132,80 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"some say the world will end in fire\n",
"some say in ice\n",
"from what i’ve tasted of desire\n",
"i hold with those who favor fire\n",
"but if it had to perish twice\n",
"i think i know enough of hate\n",
"to say that for destruction ice\n",
"is also great\n",
"and would suffice\n"
]
}
],
"source": [
"punctuation = \",.\"\n",
"\n",
"new_poem = poem.translate(str.maketrans(\"\",\"\", punctuation)).lower()\n",
"\n",
"print(new_poem)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"258"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"new_string = \"python is awesome!\"\n",
"\n",
"concat = new_poem + new_string\n",
"len(concat)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'i’ve', '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', 'sufficepython', 'is', 'awesome!']\n"
]
}
],
"source": [
"# Your code here\n"
"poem_list = concat.split()\n",
"print(poem_list)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python [conda env:base] *",
"language": "python",
"name": "python3"
"name": "conda-base-py"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -126,7 +217,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.5"
}
},
"nbformat": 4,
Expand Down