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
223 changes: 190 additions & 33 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": 16,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,11 +25,30 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 20,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"PLAY\n",
"FILLING\n",
"BAR\n",
"THEATRE\n",
"EASYGOING\n",
"DATE\n",
"LEAD\n",
"THAT\n",
"STORY\n",
"ISLAND\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"for word in words:\n",
" print(word.upper())\n"
]
},
{
Expand All @@ -41,11 +60,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"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 +89,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 25,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"theatre\n",
"that\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"for word in words:\n",
" if word.startswith(\"t\"):\n",
" print(word)"
]
},
{
Expand All @@ -80,11 +124,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 26,
"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",
"list =[]\n",
"for number in range(1,11):\n",
" number = number**2\n",
" list.append(number)\n",
"print(list)\n",
")"
]
},
{
Expand All @@ -96,11 +154,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 33,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 9, 25, 49, 81]\n",
"[1, 9, 25, 49, 81]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"list_odd =[]\n",
"for number in range(1,11):\n",
" if number%2 == 1:\n",
" number = number**2 \n",
" list_odd.append(number)\n",
"print(list_odd)\n",
"\n",
"squares = [x**2 for x in range(1, 11) if x % 2 != 0]\n",
"print(squares)\n"
]
},
{
Expand All @@ -112,11 +188,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 36,
"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, 1000]\n",
"[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, 1000]\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"multiples_eight = []\n",
"for number in range(1,1001):\n",
" if number%8 == 0: \n",
" multiples_eight.append(number)\n",
"print(multiples_eight)\n",
"\n",
"multiples_of_eight = [x for x in range(1, 1001) if x % 8 == 0]\n",
"print(multiples_eight)"
]
},
{
Expand All @@ -128,7 +221,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 37,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -170,11 +263,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 48,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"total_kids = sum(i[\"n_kids\"] for i in people)\n",
"print(total_kids)"
]
},
{
Expand All @@ -186,11 +289,25 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 49,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Name: Juan, Number of kids: 2\n",
"Name: Pepe, Number of kids: 0\n",
"Name: Sonia, Number of kids: 1\n",
"Name: Lucía, Number of kids: 2\n",
"Name: Leo, Number of kids: 5\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"for i in people:\n",
" print(f\"Name: {i['name']}, Number of kids: {i['n_kids']}\")"
]
},
{
Expand All @@ -202,11 +319,21 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 50,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"total_kids = sum(i[\"n_kids\"] for i in people)\n",
"print(total_kids)\n"
]
},
{
Expand All @@ -218,12 +345,42 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 55,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Sonia has an extra child!\n",
"Lucía has an extra child!\n",
"[{'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"
"new_people = [] \n",
"\n",
"for i in people:\n",
" \n",
" person = i.copy()\n",
" \n",
"\n",
" if person[\"name\"].endswith(\"a\"):\n",
" person[\"n_kids\"] += 1\n",
" print(f\"{person['name']} has an extra child!\")\n",
"\n",
" new_people.append(person)\n",
"\n",
"print(new_people)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -242,7 +399,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.9.12"
},
"toc": {
"base_numbering": 1,
Expand Down