diff --git a/README.md b/README.md index b0c84c4..ef5d9d6 100644 Binary files a/README.md and b/README.md differ diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..ea2355e Binary files /dev/null and b/test.txt differ diff --git a/your-code/main.ipynb b/your-code/main.ipynb index de27676..45f22f9 100644 --- a/your-code/main.ipynb +++ b/your-code/main.ipynb @@ -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']" ] }, { @@ -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())" ] }, { @@ -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)" ] }, { @@ -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" ] }, { @@ -84,7 +102,8 @@ "metadata": {}, "outputs": [], "source": [ - "# your code here" + "squares = [n**2 for n in range(1, 11)]\n", + "print(squares)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -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)" ] }, { @@ -206,7 +237,8 @@ "metadata": {}, "outputs": [], "source": [ - "# your code here" + "total_kids = sum(person[\"n_kids\"] for person in people)\n", + "print(total_kids)" ] }, { @@ -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)" ] } ],