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
185 changes: 148 additions & 37 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": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -25,11 +25,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GS\n"
]
}
],
"source": [
"# your code here"
"# your code here\n",
"print(\"GS\")"
]
},
{
Expand All @@ -41,11 +50,28 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"play\n",
"filling\n",
"bar\n",
"theatre\n",
"easygoing\n",
"date\n",
"lead\n",
"island\n"
]
}
],
"source": [
"# your code here"
"my_list = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'island']\n",
"for item in my_list:\n",
" print(item)"
]
},
{
Expand All @@ -57,11 +83,24 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"island\n"
]
}
],
"source": [
"# your code here"
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', 'story', 'island']\n",
"for word in words:\n",
" if word.startswith(\"i\"):\n",
" print(word)\n",
" break\n",
" "
]
},
{
Expand All @@ -84,7 +123,25 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]\n"
]
}
],
"source": [
"squares_1_to_10 = [x**2 for x in range(1, 11)]\n",
"print(squares_1_to_10)"
]
},
{
Expand All @@ -96,11 +153,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[1, 9, 25, 49, 81]\n"
]
}
],
"source": [
"# your code here"
"odd_squares_1_to_10 = [x**2 for x in range(1, 10) if x % 2 != 0]\n",
"print(odd_squares_1_to_10)"
]
},
{
Expand All @@ -112,11 +178,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"[64, 256, 576, 1024, 1600, 2304, 3136, 4096, 5184, 6400, 7744, 9216, 10816, 12544, 14400, 16384, 18496, 20736, 23104, 25600, 28224, 30976, 33856, 36864, 40000, 43264, 46656, 50176, 53824, 57600, 61504, 65536, 69696, 73984, 78400, 82944, 87616, 92416, 97344, 102400, 107584, 112896, 118336, 123904, 129600, 135424, 141376, 147456, 153664, 160000, 166464, 173056, 179776, 186624, 193600, 200704, 207936, 215296, 222784, 230400, 238144, 246016, 254016, 262144, 270400, 278784, 287296, 295936, 304704, 313600, 322624, 331776, 341056, 350464, 360000, 369664, 379456, 389376, 399424, 409600, 419904, 430336, 440896, 451584, 462400, 473344, 484416, 495616, 506944, 518400, 529984, 541696, 553536, 565504, 577600, 589824, 602176, 614656, 627264, 640000, 652864, 665856, 678976, 692224, 705600, 719104, 732736, 746496, 760384, 774400, 788544, 802816, 817216, 831744, 846400, 861184, 876096, 891136, 906304, 921600, 937024, 952576, 968256, 984064]\n"
]
}
],
"source": [
"# your code here"
"squares_mult_8 = [x**2 for x in range(8, 1000, 8)]\n",
"print(squares_mult_8)"
]
},
{
Expand All @@ -128,7 +203,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -170,11 +245,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"How many people are there? 5\n"
]
}
],
"source": [
"# your code here"
"num_people = len(people)\n",
"print(\"How many people are there?\", num_people)"
]
},
{
Expand All @@ -186,11 +270,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 12,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"How many people have kids? 4\n"
]
}
],
"source": [
"# your code here"
"num_with_kids = sum(1 for person in people if person[\"n_kids\"] > 0)\n",
"print(\"How many people have kids?\", num_with_kids)"
]
},
{
Expand All @@ -202,11 +295,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"How many kids do they have in total? 10\n"
]
}
],
"source": [
"# your code here"
"total_kids = sum(person[\"n_kids\"] for person in people)\n",
"print(\"How many kids do they have in total?\", total_kids)"
]
},
{
Expand All @@ -218,17 +320,31 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"in a year's time, people info:\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"
"updated_people = [\n",
" {**person, \"n_kids\": person[\"n_kids\"] + 1 if person[\"name\"].endswith(\"a\") else person[\"n_kids\"]}\n",
" for person in people\n",
"]\n",
"print(\"in a year's time, people info:\")\n",
"print(updated_people)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "base",
"language": "python",
"name": "python3"
},
Expand All @@ -242,7 +358,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.13.5"
},
"toc": {
"base_numbering": 1,
Expand Down Expand Up @@ -285,11 +401,6 @@
"_Feature"
],
"window_display": false
},
"vscode": {
"interpreter": {
"hash": "aee8b7b246df8f9039afb4144a1f6fd8d2ca17a180786b69acc140d282b71a49"
}
}
},
"nbformat": 4,
Expand Down