Skip to content
Open

done #347

Show file tree
Hide file tree
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
Binary file added anaconda_projects/db/project_filebrowser.db
Binary file not shown.
154 changes: 123 additions & 31 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,11 +25,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"words = [word.upper() for word in words]"
]
},
{
Expand All @@ -41,11 +41,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"set_word = [] # make sure this list exists first\n",
"\n",
"for word in words:\n",
" if len(word) == 5: # use len() to check the length of the string\n",
" set_word.append(word) # use .append() method properly\n"
]
},
{
Expand All @@ -57,11 +61,13 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"for word in words:\n",
" if word[0] == \"t\": # use len() to check the length of the string\n",
" print(word)"
]
},
{
Expand All @@ -80,11 +86,11 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"square = [1,4,9,16,25,36,64,72,81,100]"
]
},
{
Expand All @@ -96,11 +102,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[4, 16, 36, 64, 72, 100]\n"
]
}
],
"source": [
"# your code here"
"new_list = []\n",
"\n",
"for i in range(len(square)):\n",
" if square[i] % 2 == 0:\n",
" new_list.append(square[i])\n",
"\n",
"print(new_list)"
]
},
{
Expand All @@ -112,11 +132,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[16, 64, 72]\n"
]
}
],
"source": [
"# your code here"
"new_list = []\n",
"\n",
"for i in range(len(square)):\n",
" if square[i] % 8 == 0:\n",
" new_list.append(square[i])\n",
"\n",
"print(new_list)"
]
},
{
Expand All @@ -128,7 +162,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -170,11 +204,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"5\n"
]
}
],
"source": [
"# your code here"
"print(len(people))"
]
},
{
Expand All @@ -186,11 +228,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"4\n"
]
}
],
"source": [
"# your code here"
"count = 0\n",
"\n",
"for p in people:\n",
" if p[\"n_kids\"] > 0:\n",
" count += 1\n",
"\n",
"print(count)"
]
},
{
Expand All @@ -202,11 +258,26 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 18,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"count = 0\n",
"\n",
"for p in people:\n",
" if p[\"n_kids\"] > 0:\n",
" count += p[\"n_kids\"]\n",
"\n",
"print(count)"
]
},
{
Expand All @@ -218,19 +289,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 19,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[{'name': 'Juan', 'age': 34, 'n_kids': 2}, {'name': 'Pepe', 'age': 27, 'n_kids': 0}, {'name': 'Sonia', 'age': 41, 'n_kids': 2}, {'name': 'Lucía', 'age': 22, 'n_kids': 3}, {'name': 'Leo', 'age': 55, 'n_kids': 5}]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"next_year = []\n",
"\n",
"for p in people:\n",
" # Copy each person's data\n",
" new_person = p.copy()\n",
" \n",
" # Check if name ends with \"a\"\n",
" if p[\"name\"].endswith(\"a\"):\n",
" new_person[\"n_kids\"] += 1 # add one kid\n",
"\n",
" next_year.append(new_person)\n",
"\n",
"print(next_year)"
]
}
],
"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 @@ -242,7 +334,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.5"
},
"toc": {
"base_numbering": 1,
Expand Down