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
220 changes: 212 additions & 8 deletions cfu-data-types.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,75 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# Your code here\n"
"# Your code here\n",
"name=input(\"Please enter your information:name\")\n",
"age=int(input(\"please enter your age\"))\n",
"address=input(\"please enter your address\")\n",
"salary=int(input(\"please enter your salary\"))\n",
"expenses=int(input(\"please enter your expenses\"))\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"100\n"
]
}
],
"source": [
"remaining_salary=salary-expenses\n",
"print(remaining_salary)\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"False\n"
]
}
],
"source": [
"x=True\n",
"y=False\n",
"\n",
"if remaining_salary >=500:\n",
" print(x)\n",
"else:print(y)\n"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Nastya, who is 33 years old, and lives in Amsterdam has 100 dollars left from her salary after expenses. It is true that she has less 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 {'true' if remaining_salary < 500 else 'false'} that she has less than $500 left.\")"
]
},
{
Expand Down Expand Up @@ -85,7 +149,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -102,17 +166,157 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 29,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"str"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(poem)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"245\n"
]
}
],
"source": [
"print(len(poem))\n"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"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": [
"\n",
"poem=poem.lower()\n",
"print(poem)\n",
"\n",
"\n",
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"list"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"poem=[poem]\n",
"\n",
"type(poem)\n"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {},
"outputs": [
{
"ename": "ValueError",
"evalue": "list.remove(x): x not in list",
"output_type": "error",
"traceback": [
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
"\u001b[31mValueError\u001b[39m Traceback (most recent call last)",
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[36]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m poem.remove(\u001b[33m\",\"\u001b[39m)\n\u001b[32m 2\u001b[39m poem.remove(\u001b[33m\".\"\u001b[39m)\n\u001b[32m 3\u001b[39m print(poem)\n\u001b[32m 4\u001b[39m \n",
"\u001b[31mValueError\u001b[39m: list.remove(x): x not in list"
]
}
],
"source": [
"poem.remove(\",\")\n",
"poem.remove(\".\")\n",
"print(poem)\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['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.']python is awsome!\n"
]
}
],
"source": [
"new_poem=str(poem)+\"python is awsome!\"\n",
"print(new_poem)\n"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"274\n"
]
}
],
"source": [
"# Your code here\n"
"print(len(new_poem))\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -126,7 +330,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.14.7"
}
},
"nbformat": 4,
Expand Down