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
196 changes: 158 additions & 38 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": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,11 +25,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 14,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['PLAY', 'FILLING', 'BAR', 'THEATRE', 'EASYGOING', 'DATE', 'LEAD', 'THAT', 'STORY', 'ISLAND']\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"upper_case = []\n",
"for word in words:\n",
" upper_case.append(word.upper())\n",
"print(upper_case)\n"
]
},
{
Expand All @@ -41,11 +53,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['filling', 'theatre', 'easygoing', 'story', 'island']\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"new_list = []\n",
"for word in words:\n",
" if len(word) >= 5:\n",
" new_list.append(word)\n",
"print(new_list)"
]
},
{
Expand All @@ -57,11 +82,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['filling']\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"new_list = []\n",
"for word in words:\n",
" if word.startswith('f'):\n",
" new_list.append(word)\n",
"print(new_list)"
]
},
{
Expand All @@ -80,11 +118,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 22,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"square = []\n",
"for i in range(1, 11):\n",
" square.append(i**2)\n",
"print(square)\n"
]
},
{
Expand All @@ -98,9 +148,22 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 9, 25, 49, 81]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"odd_square = []\n",
"for i in range(1, 11):\n",
" if i % 2 != 0:\n",
" odd_square.append(i**2)\n",
"print(odd_square)"
]
},
{
Expand All @@ -112,11 +175,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, 128, 136, 144, 152, 160, 168, 176, 184, 192, 200, 208, 216, 224, 232, 240, 248, 256, 264, 272, 280, 288, 296, 304, 312, 320, 328, 336, 344, 352, 360, 368, 376, 384, 392, 400, 408, 416, 424, 432, 440, 448, 456, 464, 472, 480, 488, 496, 504, 512, 520, 528, 536, 544, 552, 560, 568, 576, 584, 592, 600, 608, 616, 624, 632, 640, 648, 656, 664, 672, 680, 688, 696, 704, 712, 720, 728, 736, 744, 752, 760, 768, 776, 784, 792, 800, 808, 816, 824, 832, 840, 848, 856, 864, 872, 880, 888, 896, 904, 912, 920, 928, 936, 944, 952, 960, 968, 976, 984, 992]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"result = []\n",
"for i in range(1,1000):\n",
" if i % 8 == 0:\n",
" result.append(i)\n",
"print(result)"
]
},
{
Expand All @@ -128,7 +204,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -170,11 +246,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"there are 5 people in the list\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"print(f\"there are {len(people)} people in the list\")"
]
},
{
Expand All @@ -186,11 +271,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 28,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"there are 4 people with kids in the list\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"people_with_kids = 0\n",
"for person in people:\n",
" if person['n_kids'] > 0:\n",
" people_with_kids += 1\n",
"print(f\"there are {people_with_kids} people with kids in the list\")"
]
},
{
Expand All @@ -202,11 +300,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 29,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"there are 10 kids in the list\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"total_kids = 0\n",
"for person in people:\n",
" total_kids += person['n_kids']\n",
"print(f\"there are {total_kids} kids in the list\")\n"
]
},
{
Expand All @@ -218,17 +328,32 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 31,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"people next year: [{'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",
"people_next_year = []\n",
"for person in people:\n",
" new_person = person.copy()\n",
" if new_person['name'].endswith('a'):\n",
" new_person['n_kids'] += 1\n",
" people_next_year.append(new_person)\n",
"print(f\"people next year: {people_next_year}\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -242,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.6"
},
"toc": {
"base_numbering": 1,
Expand Down Expand Up @@ -285,11 +410,6 @@
"_Feature"
],
"window_display": false
},
"vscode": {
"interpreter": {
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
}
}
},
"nbformat": 4,
Expand Down