Skip to content
Open
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 modified README.md
Binary file not shown.
Binary file added test.txt
Binary file not shown.
63 changes: 52 additions & 11 deletions your-code/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', 'story', 'island']"
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', 'story', 'island', 'guitar', 'swing', 'broad', 'soup', 'singer', 'sugar', 'sail', 'shelf', 'sudden', 'cable', 'dare']"
]
},
{
Expand All @@ -29,7 +29,12 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', \n",
" 'story', 'island', 'guitar', 'swing', 'broad', 'soup', 'singer', 'sugar', \n",
" 'sail', 'shelf', 'sudden', 'cable', 'dare']\n",
"\n",
"for word in words:\n",
" print(word.upper())"
]
},
{
Expand All @@ -45,7 +50,13 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', \n",
" 'story', 'island', 'guitar', 'swing', 'broad', 'soup', 'singer', 'sugar', \n",
" 'sail', 'shelf', 'sudden', 'cable', 'dare']\n",
"\n",
"long_words = [word for word in words if len(word) >= 5]\n",
"\n",
"print(long_words)"
]
},
{
Expand All @@ -61,7 +72,14 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"words = ['play', 'filling', 'bar', 'theatre', 'easygoing', 'date', 'lead', 'that', \n",
" 'story', 'island', 'guitar', 'swing', 'broad', 'soup', 'singer', 'sugar', \n",
" 'sail', 'shelf', 'sudden', 'cable', 'dare']\n",
"\n",
"for word in words:\n",
" if word.startswith(\"t\"):\n",
" print(word)\n",
" break\n"
]
},
{
Expand All @@ -84,7 +102,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"squares = [n**2 for n in range(1, 11)]\n",
"print(squares)"
]
},
{
Expand All @@ -100,7 +119,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"squares_of_multiples = [n**2 for n in range(8, 1000, 8)]\n",
"print(squares_of_multiples)"
]
},
{
Expand All @@ -116,7 +136,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"squares_of_multiples = [n**2 for n in range(8, 1000, 8)]\n",
"print(squares_of_multiples)"
]
},
{
Expand Down Expand Up @@ -174,7 +195,16 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"people = [\n",
" {\"name\": \"Juan\", \"age\": 34, \"n_kids\": 2},\n",
" {\"name\": \"Pepe\", \"age\": 27, \"n_kids\": 0},\n",
" {\"name\": \"Sonia\", \"age\": 41, \"n_kids\": 1},\n",
" {\"name\": \"Lucía\", \"age\": 22, \"n_kids\": 2},\n",
" {\"name\": \"Leo\", \"age\": 55, \"n_kids\": 5}\n",
"]\n",
"\n",
"num_people = len(people)\n",
"print(num_people)"
]
},
{
Expand All @@ -190,7 +220,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"people_with_kids = sum(1 for person in people if person[\"n_kids\"] > 0)\n",
"print(people_with_kids)"
]
},
{
Expand All @@ -206,7 +237,8 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"total_kids = sum(person[\"n_kids\"] for person in people)\n",
"print(total_kids)"
]
},
{
Expand All @@ -222,7 +254,16 @@
"metadata": {},
"outputs": [],
"source": [
"# your code here"
"people_next_year = []\n",
"\n",
"for person in people:\n",
" updated_person = person.copy() # Make a copy to avoid modifying original\n",
" updated_person[\"age\"] += 1\n",
" if person[\"name\"].endswith(\"a\"):\n",
" updated_person[\"n_kids\"] += 1\n",
" people_next_year.append(updated_person)\n",
"\n",
"print(people_next_year)"
]
}
],
Expand Down