From 67ee21f230a4de815548e4a355d550f96907b8e7 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 22 Aug 2019 23:22:34 +0000 Subject: [PATCH 01/92] first --- exercises/03- Access-and-Retrieve/README.md | 18 ++++++++++++++++++ exercises/03- Access-and-Retrieve/app.py | 0 exercises/03- Access-and-Retrieve/test.py | 0 3 files changed, 18 insertions(+) create mode 100644 exercises/03- Access-and-Retrieve/README.md create mode 100644 exercises/03- Access-and-Retrieve/app.py create mode 100644 exercises/03- Access-and-Retrieve/test.py diff --git a/exercises/03- Access-and-Retrieve/README.md b/exercises/03- Access-and-Retrieve/README.md new file mode 100644 index 00000000..ce821a6e --- /dev/null +++ b/exercises/03- Access-and-Retrieve/README.md @@ -0,0 +1,18 @@ +Instructions from your teacher: +Arrays are part of every programming language. They are the way to go when you want to have a "list of elements." + +For example, we could have an array that is storing the days of the week: + +var myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']; + +Every array has the following parts: +- Items: are the actual values inside on each position of the array. +- Length: is the size of the array, the number of items. +- Index: is the position of an element. + +To access any particular item within the array you need to know its index (position). The index is an integer value that represents the position in which the element is located. Protip: Every array starts from cero (0)! + +Instructions +Using the console.log function, print the 3rd item from the array. +Change the value in the position where 'Thursday' is located to null. +Print that particular position. diff --git a/exercises/03- Access-and-Retrieve/app.py b/exercises/03- Access-and-Retrieve/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/03- Access-and-Retrieve/test.py b/exercises/03- Access-and-Retrieve/test.py new file mode 100644 index 00000000..e69de29b From b82a5cde105b902c5d8ee44c1fda767cf552b1a8 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 23 Aug 2019 01:26:11 +0000 Subject: [PATCH 02/92] first exercise --- exercises/03- Access-and-Retrieve/app.py | 0 exercises/03- Access-and-Retrieve/test.py | 0 .../README.md | 19 +++++++++++++------ exercises/03-Access-and-Retrieve/app.py | 9 +++++++++ exercises/03-Access-and-Retrieve/test.py | 17 +++++++++++++++++ 5 files changed, 39 insertions(+), 6 deletions(-) delete mode 100644 exercises/03- Access-and-Retrieve/app.py delete mode 100644 exercises/03- Access-and-Retrieve/test.py rename exercises/{03- Access-and-Retrieve => 03-Access-and-Retrieve}/README.md (69%) create mode 100644 exercises/03-Access-and-Retrieve/app.py create mode 100644 exercises/03-Access-and-Retrieve/test.py diff --git a/exercises/03- Access-and-Retrieve/app.py b/exercises/03- Access-and-Retrieve/app.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/03- Access-and-Retrieve/test.py b/exercises/03- Access-and-Retrieve/test.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/03- Access-and-Retrieve/README.md b/exercises/03-Access-and-Retrieve/README.md similarity index 69% rename from exercises/03- Access-and-Retrieve/README.md rename to exercises/03-Access-and-Retrieve/README.md index ce821a6e..d8b3df76 100644 --- a/exercises/03- Access-and-Retrieve/README.md +++ b/exercises/03-Access-and-Retrieve/README.md @@ -1,9 +1,13 @@ -Instructions from your teacher: +# `03` Instructions from your teacher: + Arrays are part of every programming language. They are the way to go when you want to have a "list of elements." For example, we could have an array that is storing the days of the week: - +```js var myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']; +``` + +![What is an Array?](http://i.imgur.com/DbmSOHT.png) Every array has the following parts: - Items: are the actual values inside on each position of the array. @@ -12,7 +16,10 @@ Every array has the following parts: To access any particular item within the array you need to know its index (position). The index is an integer value that represents the position in which the element is located. Protip: Every array starts from cero (0)! -Instructions -Using the console.log function, print the 3rd item from the array. -Change the value in the position where 'Thursday' is located to null. -Print that particular position. +## 📝 Instructions + +1. Using the print() function, print the 3rd item from the array. +2. Change the value in the position where 'Thursday' is located to None. +3. Print the particular position of the step two. + + diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py new file mode 100644 index 00000000..9bdd9b9c --- /dev/null +++ b/exercises/03-Access-and-Retrieve/app.py @@ -0,0 +1,9 @@ + +my_Array = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] + +#1. print the item here +print(my_Array[2]) +#2. change 'thursday' a value here to null +my_Array[4] = None +#3. print the position of step 2 +print(None) \ No newline at end of file diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/03-Access-and-Retrieve/test.py new file mode 100644 index 00000000..a13786a5 --- /dev/null +++ b/exercises/03-Access-and-Retrieve/test.py @@ -0,0 +1,17 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_Array +import pytest + + +@pytest.mark.it('Your console have to print the 3rd item from array') +def test_output_good(): + print(my_Array[2]) + captured = buffer.getvalue() + assert captured == "tuesday\n" + +@pytest.mark.it('This value should change to null') +def test_for_change_output(): + assert my_Array[4] is None From eb604f6065afb29f55b3d63eb00d9ffdc7a4b7a9 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 23 Aug 2019 03:16:59 +0000 Subject: [PATCH 03/92] 04 and 05 exercise --- exercises/03-Access-and-Retrieve/app.py | 8 ++++---- exercises/03-Access-and-Retrieve/test.py | 10 +++++++--- exercises/04-Retrieve-items/README.md | 12 ++++++++++++ exercises/04-Retrieve-items/app.py | 6 ++++++ exercises/04-Retrieve-items/test.py | 14 ++++++++++++++ exercises/05-Print-the-last-one/README.md | 14 ++++++++++++++ exercises/05-Print-the-last-one/app.py | 0 exercises/05-Print-the-last-one/test.py | 11 +++++++++++ 8 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 exercises/04-Retrieve-items/README.md create mode 100644 exercises/04-Retrieve-items/app.py create mode 100644 exercises/04-Retrieve-items/test.py create mode 100644 exercises/05-Print-the-last-one/README.md create mode 100644 exercises/05-Print-the-last-one/app.py create mode 100644 exercises/05-Print-the-last-one/test.py diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index 9bdd9b9c..91714079 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -2,8 +2,8 @@ my_Array = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_Array[2]) -#2. change 'thursday' a value here to null -my_Array[4] = None + +#2. change 'thursday'a value here to None + #3. print the position of step 2 -print(None) \ No newline at end of file + diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/03-Access-and-Retrieve/test.py index a13786a5..bd5a0d4d 100644 --- a/exercises/03-Access-and-Retrieve/test.py +++ b/exercises/03-Access-and-Retrieve/test.py @@ -10,8 +10,12 @@ def test_output_good(): print(my_Array[2]) captured = buffer.getvalue() - assert captured == "tuesday\n" + assert captured == "tuesday\n""None\n" -@pytest.mark.it('This value should change to null') +@pytest.mark.it('This value should change to None') def test_for_change_output(): - assert my_Array[4] is None + assert my_Array[4] == "None" + +@pytest.mark.it('Your code have to print the position of step 2') +def test_position_output(): + assert my_Array[4] == "None" \ No newline at end of file diff --git a/exercises/04-Retrieve-items/README.md b/exercises/04-Retrieve-items/README.md new file mode 100644 index 00000000..0cb8d3e4 --- /dev/null +++ b/exercises/04-Retrieve-items/README.md @@ -0,0 +1,12 @@ +# `04` Instructions from your teacher: +The only way of accessing a particular element in an `array` is using an index. +An `index` is an integer number that represents the `position` you want to access in the array. + +You need to `wrap` the index into `brackets` like this: +```js +var myValue = array[index]; +``` + +## 📝 Instructions +1. Print on the console the 1st element of the array +2. Print on the console the 4th element of the array diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py new file mode 100644 index 00000000..7bcc96c4 --- /dev/null +++ b/exercises/04-Retrieve-items/app.py @@ -0,0 +1,6 @@ +arr = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] + +# print the 1st element + +# print the 4th element + diff --git a/exercises/04-Retrieve-items/test.py b/exercises/04-Retrieve-items/test.py new file mode 100644 index 00000000..b3ad7af1 --- /dev/null +++ b/exercises/04-Retrieve-items/test.py @@ -0,0 +1,14 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import arr +import pytest + +@pytest.mark.it('You have to print the 1st element of the array') +def test_output(): + assert arr[0] == 4 + +@pytest.mark.it('You have to print the 4th element of the array') +def test_output_item(): + assert arr[3] == 43 diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md new file mode 100644 index 00000000..caae98c7 --- /dev/null +++ b/exercises/05-Print-the-last-one/README.md @@ -0,0 +1,14 @@ +# `05` Instructions from your teacher: + +You will never know how many `items` myStupidArray has because it is being `randomly` generated during runtime. + +You know that the property +```js +SOMEARRAY.length +``` +returns the `length of` SOMEARRAY. + +## 📝 Instructions + +1. Create a variable named theLastOne, and assign it the LAST element of myStupidArray. +2. Then, print it on the console. \ No newline at end of file diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py new file mode 100644 index 00000000..73dfff08 --- /dev/null +++ b/exercises/05-Print-the-last-one/test.py @@ -0,0 +1,11 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import +import pytest + + +@pytest.mark.it() +@pytest.mark.it() +@pytest.mark.it() \ No newline at end of file From 2424cd93b656b90a8596edf1fefe11375065f17f Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 23 Aug 2019 23:27:58 +0000 Subject: [PATCH 04/92] readme 06-07 --- exercises/06-Add-item-to-list/README.md | 8 ++++++++ exercises/07-Loop-from-1-to-17/README.md | 11 +++++++++++ exercises/07-Loop-from-1-to-17/app.py | 0 exercises/07-Loop-from-1-to-17/test.py | 0 4 files changed, 19 insertions(+) create mode 100644 exercises/06-Add-item-to-list/README.md create mode 100644 exercises/07-Loop-from-1-to-17/README.md create mode 100644 exercises/07-Loop-from-1-to-17/app.py create mode 100644 exercises/07-Loop-from-1-to-17/test.py diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md new file mode 100644 index 00000000..36476c5a --- /dev/null +++ b/exercises/06-Add-item-to-list/README.md @@ -0,0 +1,8 @@ +# `06` Instructions from your teacher: +```js +Add 10 random integers to the "arr" list. +``` + +💡Tips: +You can use the `Math.random()` and `Math.floor()` functions to get random numbers. +Search on Google how to use random and floor functions. \ No newline at end of file diff --git a/exercises/07-Loop-from-1-to-17/README.md b/exercises/07-Loop-from-1-to-17/README.md new file mode 100644 index 00000000..e9302f83 --- /dev/null +++ b/exercises/07-Loop-from-1-to-17/README.md @@ -0,0 +1,11 @@ +# `07` Instructions from your teacher: +Count from 1 to 17 with a `loop` and `print` each number on the console. + +💡HINT: +```js +You have to loop from 1 to 17. +``` + +Expected console result: + +![Loop from 1 to 17](https://storage.googleapis.com/replit/images/1551487703251_476381238e5892248e9417fc4a069931.pn) \ No newline at end of file diff --git a/exercises/07-Loop-from-1-to-17/app.py b/exercises/07-Loop-from-1-to-17/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/07-Loop-from-1-to-17/test.py b/exercises/07-Loop-from-1-to-17/test.py new file mode 100644 index 00000000..e69de29b From cb54cbac91720455098ed5e94b36569f038ebfcf Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 23 Aug 2019 23:38:55 +0000 Subject: [PATCH 05/92] readme 07 --- exercises/03-Access-and-Retrieve/README.md | 2 +- exercises/07-Loop-from-1-to-17/README.md | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/exercises/03-Access-and-Retrieve/README.md b/exercises/03-Access-and-Retrieve/README.md index d8b3df76..455929b0 100644 --- a/exercises/03-Access-and-Retrieve/README.md +++ b/exercises/03-Access-and-Retrieve/README.md @@ -1,4 +1,4 @@ -# `03` Instructions from your teacher: +test.py # `03` Instructions from your teacher: Arrays are part of every programming language. They are the way to go when you want to have a "list of elements." diff --git a/exercises/07-Loop-from-1-to-17/README.md b/exercises/07-Loop-from-1-to-17/README.md index e9302f83..a0d6965f 100644 --- a/exercises/07-Loop-from-1-to-17/README.md +++ b/exercises/07-Loop-from-1-to-17/README.md @@ -1,11 +1,12 @@ # `07` Instructions from your teacher: -Count from 1 to 17 with a `loop` and `print` each number on the console. -💡HINT: ```js -You have to loop from 1 to 17. +Count from 1 to 17 with a loop and print each number on the console. ``` +💡HINT: +You have to loop from 1 to 17. + Expected console result: ![Loop from 1 to 17](https://storage.googleapis.com/replit/images/1551487703251_476381238e5892248e9417fc4a069931.pn) \ No newline at end of file From 38957a5e2d4245a925af9641943691bb0498704d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 23 Aug 2019 23:58:24 +0000 Subject: [PATCH 06/92] readme --- exercises/03-Access-and-Retrieve/README.md | 14 +++++++++----- exercises/05-Print-the-last-one/README.md | 1 + exercises/05-Print-the-last-one/test.py | 11 ----------- exercises/07-Loop-from-1-to-17/README.md | 12 ------------ exercises/07-Loop-from-1-to-17/app.py | 0 exercises/07-Loop-from-1-to-17/test.py | 0 exercises/sample/README.md | 1 + 7 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 exercises/07-Loop-from-1-to-17/README.md delete mode 100644 exercises/07-Loop-from-1-to-17/app.py delete mode 100644 exercises/07-Loop-from-1-to-17/test.py create mode 100644 exercises/sample/README.md diff --git a/exercises/03-Access-and-Retrieve/README.md b/exercises/03-Access-and-Retrieve/README.md index 455929b0..7d765344 100644 --- a/exercises/03-Access-and-Retrieve/README.md +++ b/exercises/03-Access-and-Retrieve/README.md @@ -10,11 +10,14 @@ var myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','satu ![What is an Array?](http://i.imgur.com/DbmSOHT.png) Every array has the following parts: -- Items: are the actual values inside on each position of the array. -- Length: is the size of the array, the number of items. -- Index: is the position of an element. - -To access any particular item within the array you need to know its index (position). The index is an integer value that represents the position in which the element is located. Protip: Every array starts from cero (0)! +- `Items:` are the actual values inside on each position of the array. +- `Length:` is the size of the array, the number of items. +- `Index:` is the position of an element. +```py +To access any particular item within the array you need to know its index (position). +The index is an integer value that represents the position in which the element is located. +Protip: Every array starts from cero (0)! +``` ## 📝 Instructions @@ -23,3 +26,4 @@ To access any particular item within the array you need to know its index (posit 3. Print the particular position of the step two. + diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md index caae98c7..6f31fff5 100644 --- a/exercises/05-Print-the-last-one/README.md +++ b/exercises/05-Print-the-last-one/README.md @@ -6,6 +6,7 @@ You know that the property ```js SOMEARRAY.length ``` + returns the `length of` SOMEARRAY. ## 📝 Instructions diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index 73dfff08..e69de29b 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -1,11 +0,0 @@ -import io -import sys -sys.stdout = buffer = io.StringIO() - -from app import -import pytest - - -@pytest.mark.it() -@pytest.mark.it() -@pytest.mark.it() \ No newline at end of file diff --git a/exercises/07-Loop-from-1-to-17/README.md b/exercises/07-Loop-from-1-to-17/README.md deleted file mode 100644 index a0d6965f..00000000 --- a/exercises/07-Loop-from-1-to-17/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# `07` Instructions from your teacher: - -```js -Count from 1 to 17 with a loop and print each number on the console. -``` - -💡HINT: -You have to loop from 1 to 17. - -Expected console result: - -![Loop from 1 to 17](https://storage.googleapis.com/replit/images/1551487703251_476381238e5892248e9417fc4a069931.pn) \ No newline at end of file diff --git a/exercises/07-Loop-from-1-to-17/app.py b/exercises/07-Loop-from-1-to-17/app.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/07-Loop-from-1-to-17/test.py b/exercises/07-Loop-from-1-to-17/test.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/sample/README.md b/exercises/sample/README.md new file mode 100644 index 00000000..6cdd5335 --- /dev/null +++ b/exercises/sample/README.md @@ -0,0 +1 @@ +dimelo es una prueba \ No newline at end of file From 74cb069c3d9c85de33b9c773a26026c835b875e8 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 25 Aug 2019 03:53:17 +0000 Subject: [PATCH 07/92] 07 --- exercises/03-Access-and-Retrieve/app.py | 6 +++--- exercises/06-Add-item-to-list/app.py | 0 exercises/06-Add-item-to-list/test.py | 0 exercises/07loop_from_1_to_17/README.md | 11 +++++++++++ exercises/07loop_from_1_to_17/app.py | 1 + exercises/07loop_from_1_to_17/test.py | 5 +++++ exercises/sample/README.md | 1 - 7 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 exercises/06-Add-item-to-list/app.py create mode 100644 exercises/06-Add-item-to-list/test.py create mode 100644 exercises/07loop_from_1_to_17/README.md create mode 100644 exercises/07loop_from_1_to_17/app.py create mode 100644 exercises/07loop_from_1_to_17/test.py delete mode 100644 exercises/sample/README.md diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index 91714079..84ee39d2 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -2,8 +2,8 @@ my_Array = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here - +print(my_Array[2]) #2. change 'thursday'a value here to None - +my_Array[4] = "None" #3. print the position of step 2 - +print(my_Array) diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/07loop_from_1_to_17/README.md b/exercises/07loop_from_1_to_17/README.md new file mode 100644 index 00000000..f149143a --- /dev/null +++ b/exercises/07loop_from_1_to_17/README.md @@ -0,0 +1,11 @@ +# `07` Instructions from your teacher: + +```js +Count from 1 to 17 with a loop and print each number on the console. +``` + +💡HINT: +You have to loop from 1 to 17. + +Expected console result: +![Loop from 1 to 17](https://storage.googleapis.com/replit/images/1551487703251_476381238e5892248e9417fc4a069931.pn) \ No newline at end of file diff --git a/exercises/07loop_from_1_to_17/app.py b/exercises/07loop_from_1_to_17/app.py new file mode 100644 index 00000000..19a6c990 --- /dev/null +++ b/exercises/07loop_from_1_to_17/app.py @@ -0,0 +1 @@ +#Create your code below: diff --git a/exercises/07loop_from_1_to_17/test.py b/exercises/07loop_from_1_to_17/test.py new file mode 100644 index 00000000..2ea0396f --- /dev/null +++ b/exercises/07loop_from_1_to_17/test.py @@ -0,0 +1,5 @@ +import io +import sys +sys.stdout = bufer = io.StringIO() + + diff --git a/exercises/sample/README.md b/exercises/sample/README.md deleted file mode 100644 index 6cdd5335..00000000 --- a/exercises/sample/README.md +++ /dev/null @@ -1 +0,0 @@ -dimelo es una prueba \ No newline at end of file From cd2c772c1cf08583d256428d4083346b29050ee8 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 25 Aug 2019 04:14:24 +0000 Subject: [PATCH 08/92] 08 exercise --- exercises/04-Retrieve-items/app.py | 3 +-- exercises/04-Retrieve-items/test.py | 10 +++++----- exercises/08-Loop-list/README.md | 10 ++++++++++ exercises/08-Loop-list/app.py | 3 +++ exercises/08-Loop-list/test.py | 11 +++++++++++ 5 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 exercises/08-Loop-list/README.md create mode 100644 exercises/08-Loop-list/app.py create mode 100644 exercises/08-Loop-list/test.py diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 7bcc96c4..88f4eccf 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -1,6 +1,5 @@ -arr = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] +list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] # print the 1st element # print the 4th element - diff --git a/exercises/04-Retrieve-items/test.py b/exercises/04-Retrieve-items/test.py index b3ad7af1..590c2393 100644 --- a/exercises/04-Retrieve-items/test.py +++ b/exercises/04-Retrieve-items/test.py @@ -2,13 +2,13 @@ import sys sys.stdout = buffer = io.StringIO() -from app import arr +from app import list import pytest -@pytest.mark.it('You have to print the 1st element of the array') +@pytest.mark.it('You have to print the 1st element of the list') def test_output(): - assert arr[0] == 4 + assert list[0] == 4 -@pytest.mark.it('You have to print the 4th element of the array') +@pytest.mark.it('You have to print the 4th element of the list') def test_output_item(): - assert arr[3] == 43 + assert list[3] == 43 diff --git a/exercises/08-Loop-list/README.md b/exercises/08-Loop-list/README.md new file mode 100644 index 00000000..01dcb406 --- /dev/null +++ b/exercises/08-Loop-list/README.md @@ -0,0 +1,10 @@ +# `08` Instructions from your teacher: + +The code right now is `printing the first item in the console.` Instead of doing that, print `all the elements` in the array. +```js +You will have to loop through the whole array using a loop. +``` + +💡HINT +1. Remember that to access the value of a position you have to use the index +2. console.log(myArray[index]); \ No newline at end of file diff --git a/exercises/08-Loop-list/app.py b/exercises/08-Loop-list/app.py new file mode 100644 index 00000000..4c35af78 --- /dev/null +++ b/exercises/08-Loop-list/app.py @@ -0,0 +1,3 @@ +my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5] + +#You don't to change nothing above, your code go below: \ No newline at end of file diff --git a/exercises/08-Loop-list/test.py b/exercises/08-Loop-list/test.py new file mode 100644 index 00000000..ff2d3eeb --- /dev/null +++ b/exercises/08-Loop-list/test.py @@ -0,0 +1,11 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_list +import pytest + +@pytest.mark.it("You have to print the all item from the list") +def test_loop(): + for i in my_list: + print(i) From 2745c9c5c1d4729e0cf88afd7ceff8be2e41b4bf Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 25 Aug 2019 04:58:58 +0000 Subject: [PATCH 09/92] 10 exercise --- exercises/03-Access-and-Retrieve/README.md | 16 ++++++++-------- exercises/03-Access-and-Retrieve/app.py | 8 ++++---- exercises/03-Access-and-Retrieve/test.py | 8 ++++---- exercises/07loop_from_1_to_17/test.py | 1 - exercises/08-Loop-list/test.py | 4 ++-- exercises/09-Loop-from-the-top/README.md | 15 +++++++++++++++ exercises/09-Loop-from-the-top/app.py | 2 ++ exercises/09-Loop-from-the-top/test.py | 11 +++++++++++ exercises/10-Loop-adding-two/README.md | 18 ++++++++++++++++++ exercises/10-Loop-adding-two/app.py | 3 +++ exercises/10-Loop-adding-two/test.py | 9 +++++++++ 11 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 exercises/09-Loop-from-the-top/README.md create mode 100644 exercises/09-Loop-from-the-top/app.py create mode 100644 exercises/09-Loop-from-the-top/test.py create mode 100644 exercises/10-Loop-adding-two/README.md create mode 100644 exercises/10-Loop-adding-two/app.py create mode 100644 exercises/10-Loop-adding-two/test.py diff --git a/exercises/03-Access-and-Retrieve/README.md b/exercises/03-Access-and-Retrieve/README.md index 7d765344..478b4e86 100644 --- a/exercises/03-Access-and-Retrieve/README.md +++ b/exercises/03-Access-and-Retrieve/README.md @@ -1,17 +1,17 @@ -test.py # `03` Instructions from your teacher: + # `03` Instructions from your teacher: -Arrays are part of every programming language. They are the way to go when you want to have a "list of elements." +Lists are part of every programming language. They are the way to go when you want to have a "list of elements." For example, we could have an array that is storing the days of the week: ```js -var myArray = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']; +my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']; ``` -![What is an Array?](http://i.imgur.com/DbmSOHT.png) +![What is an list?](http://i.imgur.com/DbmSOHT.png) -Every array has the following parts: -- `Items:` are the actual values inside on each position of the array. -- `Length:` is the size of the array, the number of items. +Every list has the following parts: +- `Items:` are the actual values inside on each position of the list. +- `Length:` is the size of the list, the number of items. - `Index:` is the position of an element. ```py To access any particular item within the array you need to know its index (position). @@ -21,7 +21,7 @@ Protip: Every array starts from cero (0)! ## 📝 Instructions -1. Using the print() function, print the 3rd item from the array. +1. Using the print() function, print the 3rd item from the list. 2. Change the value in the position where 'Thursday' is located to None. 3. Print the particular position of the step two. diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index 84ee39d2..62c1e929 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -1,9 +1,9 @@ -my_Array = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] +my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_Array[2]) +print(my_list[2]) #2. change 'thursday'a value here to None -my_Array[4] = "None" +my_list[4] = "None" #3. print the position of step 2 -print(my_Array) +print(my_list) diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/03-Access-and-Retrieve/test.py index bd5a0d4d..856edeac 100644 --- a/exercises/03-Access-and-Retrieve/test.py +++ b/exercises/03-Access-and-Retrieve/test.py @@ -2,20 +2,20 @@ import sys sys.stdout = buffer = io.StringIO() -from app import my_Array +from app import my_list import pytest @pytest.mark.it('Your console have to print the 3rd item from array') def test_output_good(): - print(my_Array[2]) + print(my_list[2]) captured = buffer.getvalue() assert captured == "tuesday\n""None\n" @pytest.mark.it('This value should change to None') def test_for_change_output(): - assert my_Array[4] == "None" + assert my_list[4] == "None" @pytest.mark.it('Your code have to print the position of step 2') def test_position_output(): - assert my_Array[4] == "None" \ No newline at end of file + assert my_list[4] == "None" \ No newline at end of file diff --git a/exercises/07loop_from_1_to_17/test.py b/exercises/07loop_from_1_to_17/test.py index 2ea0396f..333f6888 100644 --- a/exercises/07loop_from_1_to_17/test.py +++ b/exercises/07loop_from_1_to_17/test.py @@ -2,4 +2,3 @@ import sys sys.stdout = bufer = io.StringIO() - diff --git a/exercises/08-Loop-list/test.py b/exercises/08-Loop-list/test.py index ff2d3eeb..f2ef728f 100644 --- a/exercises/08-Loop-list/test.py +++ b/exercises/08-Loop-list/test.py @@ -7,5 +7,5 @@ @pytest.mark.it("You have to print the all item from the list") def test_loop(): - for i in my_list: - print(i) + for num in my_list: + print(num) diff --git a/exercises/09-Loop-from-the-top/README.md b/exercises/09-Loop-from-the-top/README.md new file mode 100644 index 00000000..df30caf8 --- /dev/null +++ b/exercises/09-Loop-from-the-top/README.md @@ -0,0 +1,15 @@ +# `09` Instructions from your teacher: +```js +This loop is `looping` the list from beginning to end... increasing one by one. +``` + +# 📝Instructions +Lets try looping from the end to the beginning. + +💡HINT +1. Remember the loop works like this: https://www.youtube.com/watch?v=TSMzvFwpE_A +2. The last position of the array will be mySampleArray.length - 1 because arrays start at 0 + + +The console output should be something like this: +![Loop from the top](http://i.imgur.com/ugP1QA4.png) \ No newline at end of file diff --git a/exercises/09-Loop-from-the-top/app.py b/exercises/09-Loop-from-the-top/app.py new file mode 100644 index 00000000..ad10a7dd --- /dev/null +++ b/exercises/09-Loop-from-the-top/app.py @@ -0,0 +1,2 @@ +my_sample_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] +#nothing change above, the magic pass below: \ No newline at end of file diff --git a/exercises/09-Loop-from-the-top/test.py b/exercises/09-Loop-from-the-top/test.py new file mode 100644 index 00000000..b3162cd5 --- /dev/null +++ b/exercises/09-Loop-from-the-top/test.py @@ -0,0 +1,11 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_sample_list +import pytest + +@pytest.mark.it('Try looping from the end to the beginning') +def test_loop(): + for i in reversed(my_sample_list): + print(i) diff --git a/exercises/10-Loop-adding-two/README.md b/exercises/10-Loop-adding-two/README.md new file mode 100644 index 00000000..4695fefa --- /dev/null +++ b/exercises/10-Loop-adding-two/README.md @@ -0,0 +1,18 @@ +# `10` Instructions from your teacher: +```js +This code is `looping` the whole array, `one by one`. +``` + +# 📝Instructions +Change the loop so it loops `two by two` instead of one by one. + +The console output should be something like: +```js +3423 +4 +654 +867543 +48 +55 +25 +``` \ No newline at end of file diff --git a/exercises/10-Loop-adding-two/app.py b/exercises/10-Loop-adding-two/app.py new file mode 100644 index 00000000..3bd5a361 --- /dev/null +++ b/exercises/10-Loop-adding-two/app.py @@ -0,0 +1,3 @@ +my_sample_list= [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] + +#your code go below of this line, nothing change above: \ No newline at end of file diff --git a/exercises/10-Loop-adding-two/test.py b/exercises/10-Loop-adding-two/test.py new file mode 100644 index 00000000..5cb55e0e --- /dev/null +++ b/exercises/10-Loop-adding-two/test.py @@ -0,0 +1,9 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_sample_list +import pytest + +@pytest.mark.it("loop two by two") +def test_loop(): From bc1957dd0041f122aa6157100193d6ab2a566098 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 25 Aug 2019 20:43:49 +0000 Subject: [PATCH 10/92] 06 exercises --- exercises/06-Add-item-to-list/README.md | 9 ++- exercises/06-Add-item-to-list/app.py | 2 + exercises/06-Add-item-to-list/test.py | 10 +++ .../README.md | 0 .../app.py | 0 .../test.py | 0 exercises/08-Loop-list/README.md | 61 ++++++++++++++++++- exercises/09-Loop-from-the-top/README.md | 17 +++++- 8 files changed, 95 insertions(+), 4 deletions(-) rename exercises/{07loop_from_1_to_17 => 07-loop-seventeen}/README.md (100%) rename exercises/{07loop_from_1_to_17 => 07-loop-seventeen}/app.py (100%) rename exercises/{07loop_from_1_to_17 => 07-loop-seventeen}/test.py (100%) diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md index 36476c5a..8d1b141f 100644 --- a/exercises/06-Add-item-to-list/README.md +++ b/exercises/06-Add-item-to-list/README.md @@ -4,5 +4,10 @@ Add 10 random integers to the "arr" list. ``` 💡Tips: -You can use the `Math.random()` and `Math.floor()` functions to get random numbers. -Search on Google how to use random and floor functions. \ No newline at end of file +You can use the `random()` function to get random numbers. +Search on Google how to use random function. + +Expected in the console: +```js +[4, 5, 734, 43, 45, 36, 2, 88, 12, 87, 79, 96, 58, 46, 7] +``` \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index e69de29b..d4071696 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -0,0 +1,2 @@ +list = [4,5,734,43,45] +#Your code here: diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index e69de29b..49bce379 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -0,0 +1,10 @@ +import io +import sys +sysstdout = buffer = io.StringI() + +from app import list +import pytest + +@pytest.mark.it("add ten random numbers") +def test_random(): + assert print(list) diff --git a/exercises/07loop_from_1_to_17/README.md b/exercises/07-loop-seventeen/README.md similarity index 100% rename from exercises/07loop_from_1_to_17/README.md rename to exercises/07-loop-seventeen/README.md diff --git a/exercises/07loop_from_1_to_17/app.py b/exercises/07-loop-seventeen/app.py similarity index 100% rename from exercises/07loop_from_1_to_17/app.py rename to exercises/07-loop-seventeen/app.py diff --git a/exercises/07loop_from_1_to_17/test.py b/exercises/07-loop-seventeen/test.py similarity index 100% rename from exercises/07loop_from_1_to_17/test.py rename to exercises/07-loop-seventeen/test.py diff --git a/exercises/08-Loop-list/README.md b/exercises/08-Loop-list/README.md index 01dcb406..ffff8544 100644 --- a/exercises/08-Loop-list/README.md +++ b/exercises/08-Loop-list/README.md @@ -7,4 +7,63 @@ You will have to loop through the whole array using a loop. 💡HINT 1. Remember that to access the value of a position you have to use the index -2. console.log(myArray[index]); \ No newline at end of file +2. console.log(myArray[index]); + +Expected console result: +```js +232 +32 +1 +4 +55 +4 +3 +32 +3 +24 +5 +5 +5 +34 +2 +3 +5 +5365743 +52 +34 +3 +55 +33 +435 +4 +6 +54 +63 +45 +4 +67 +56 +47 +1 +34 +54 +32 +54 +1 +78 +98 +0 +9 +8 +98 +76 +7 +54 +2 +3 +42 +456 +4 +3321 +5 +``` \ No newline at end of file diff --git a/exercises/09-Loop-from-the-top/README.md b/exercises/09-Loop-from-the-top/README.md index df30caf8..2ec6476e 100644 --- a/exercises/09-Loop-from-the-top/README.md +++ b/exercises/09-Loop-from-the-top/README.md @@ -12,4 +12,19 @@ Lets try looping from the end to the beginning. The console output should be something like this: -![Loop from the top](http://i.imgur.com/ugP1QA4.png) \ No newline at end of file +```js +12 +25 +23 +55 +56432 +48 +23 +867543 +8 +654 +47889 +4 +5 +3423 +``` \ No newline at end of file From a7e833eea077d542f15845616da6c2b3f533f7de Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 25 Aug 2019 21:45:49 +0000 Subject: [PATCH 11/92] 05 exercises --- exercises/04-Retrieve-items/test.py | 1 + exercises/06-Add-item-to-list/app.py | 3 ++- exercises/06-Add-item-to-list/test.py | 5 +++-- exercises/07-loop-seventeen/README.md | 20 +++++++++++++++++++- exercises/07-loop-seventeen/app.py | 3 ++- exercises/07-loop-seventeen/test.py | 4 +++- 6 files changed, 30 insertions(+), 6 deletions(-) diff --git a/exercises/04-Retrieve-items/test.py b/exercises/04-Retrieve-items/test.py index 590c2393..b091e58a 100644 --- a/exercises/04-Retrieve-items/test.py +++ b/exercises/04-Retrieve-items/test.py @@ -5,6 +5,7 @@ from app import list import pytest + @pytest.mark.it('You have to print the 1st element of the list') def test_output(): assert list[0] == 4 diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index d4071696..4eeba6f0 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,2 +1,3 @@ +import random list = [4,5,734,43,45] -#Your code here: +#Your code here: \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index 49bce379..f51bfe66 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -1,10 +1,11 @@ import io import sys -sysstdout = buffer = io.StringI() +sys.stdout = buffer = io.StringIO() from app import list import pytest @pytest.mark.it("add ten random numbers") def test_random(): - assert print(list) + captured = buffer.getvalue() + assert captured == print(list) diff --git a/exercises/07-loop-seventeen/README.md b/exercises/07-loop-seventeen/README.md index f149143a..b087c413 100644 --- a/exercises/07-loop-seventeen/README.md +++ b/exercises/07-loop-seventeen/README.md @@ -8,4 +8,22 @@ Count from 1 to 17 with a loop and print each number on the console. You have to loop from 1 to 17. Expected console result: -![Loop from 1 to 17](https://storage.googleapis.com/replit/images/1551487703251_476381238e5892248e9417fc4a069931.pn) \ No newline at end of file +```js +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +``` \ No newline at end of file diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index 19a6c990..ebaef9c7 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1 +1,2 @@ -#Create your code below: +#Create your here: + diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index 333f6888..9f2fd8e7 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -1,4 +1,6 @@ import io import sys -sys.stdout = bufer = io.StringIO() +sys.stdout = buffer = io.StringIO() + + From ada35982a7cb5db8ae4cac10aa8406d99822ba7d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 27 Aug 2019 01:05:12 +0000 Subject: [PATCH 12/92] test of exercises --- exercises/02-hello-world/app.py | 23 ++++++++++++++++++++--- exercises/03-Access-and-Retrieve/app.py | 7 ++++--- exercises/03-Access-and-Retrieve/test.py | 2 +- exercises/04-Retrieve-items/README.md | 10 +++++----- exercises/04-Retrieve-items/app.py | 5 +++-- exercises/04-Retrieve-items/test.py | 8 +++++--- exercises/06-Add-item-to-list/README.md | 3 ++- exercises/06-Add-item-to-list/app.py | 6 +++++- exercises/06-Add-item-to-list/test.py | 10 +++++++--- exercises/07-loop-seventeen/app.py | 2 ++ exercises/07-loop-seventeen/test.py | 5 +++++ 11 files changed, 59 insertions(+), 22 deletions(-) diff --git a/exercises/02-hello-world/app.py b/exercises/02-hello-world/app.py index 809f9002..47cd21e2 100644 --- a/exercises/02-hello-world/app.py +++ b/exercises/02-hello-world/app.py @@ -1,5 +1,22 @@ +#You have to print `hello` in the console, your code go here: +def my_function(): + return True print("hello") -def my_function(): - print("Hello Inside Function") - return True + + + + + + + + + + + + +# print("hello") + +# def my_function(): +# print("Hello Inside Function") +# return True diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index 62c1e929..39ff0606 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -2,8 +2,9 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_list[2]) + #2. change 'thursday'a value here to None -my_list[4] = "None" + #3. print the position of step 2 -print(my_list) + + diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/03-Access-and-Retrieve/test.py index 856edeac..e312f622 100644 --- a/exercises/03-Access-and-Retrieve/test.py +++ b/exercises/03-Access-and-Retrieve/test.py @@ -6,7 +6,7 @@ import pytest -@pytest.mark.it('Your console have to print the 3rd item from array') +@pytest.mark.it('Your console have to print the 3rd item from the `list`') def test_output_good(): print(my_list[2]) captured = buffer.getvalue() diff --git a/exercises/04-Retrieve-items/README.md b/exercises/04-Retrieve-items/README.md index 0cb8d3e4..7d2fa738 100644 --- a/exercises/04-Retrieve-items/README.md +++ b/exercises/04-Retrieve-items/README.md @@ -1,12 +1,12 @@ # `04` Instructions from your teacher: -The only way of accessing a particular element in an `array` is using an index. -An `index` is an integer number that represents the `position` you want to access in the array. +The only way of accessing a particular element in an `list`(in python), is using an index. +An `index` is an integer number that represents the `position` you want to access in the list. You need to `wrap` the index into `brackets` like this: ```js -var myValue = array[index]; +my_value = list[index]; ``` ## 📝 Instructions -1. Print on the console the 1st element of the array -2. Print on the console the 4th element of the array +1. Print on the console the 1st element of the list +2. Print on the console the 4th element of the list diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 88f4eccf..74054f88 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -1,5 +1,6 @@ -list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] +my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] # print the 1st element - +print(my_list[0]) # print the 4th element +print(my_list[3]) \ No newline at end of file diff --git a/exercises/04-Retrieve-items/test.py b/exercises/04-Retrieve-items/test.py index b091e58a..1f9a5a5e 100644 --- a/exercises/04-Retrieve-items/test.py +++ b/exercises/04-Retrieve-items/test.py @@ -2,14 +2,16 @@ import sys sys.stdout = buffer = io.StringIO() -from app import list +from app import my_list import pytest @pytest.mark.it('You have to print the 1st element of the list') def test_output(): - assert list[0] == 4 + print(my_list[0]) + assert my_list[0] == 4 @pytest.mark.it('You have to print the 4th element of the list') def test_output_item(): - assert list[3] == 43 + print(my_list[3]) + assert my_list[3] == 43 diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md index 8d1b141f..1193ade9 100644 --- a/exercises/06-Add-item-to-list/README.md +++ b/exercises/06-Add-item-to-list/README.md @@ -4,10 +4,11 @@ Add 10 random integers to the "arr" list. ``` 💡Tips: +You have to import random You can use the `random()` function to get random numbers. Search on Google how to use random function. -Expected in the console: +Expected in the console something similar like this: ```js [4, 5, 734, 43, 45, 36, 2, 88, 12, 87, 79, 96, 58, 46, 7] ``` \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 4eeba6f0..4d59f2da 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,3 +1,7 @@ import random + list = [4,5,734,43,45] -#Your code here: \ No newline at end of file +#Your code here: +for i in range(0, 10): + list.append(random.randint(0, 100)) +print(list) \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index f51bfe66..9fd84109 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -5,7 +5,11 @@ from app import list import pytest -@pytest.mark.it("add ten random numbers") -def test_random(): - captured = buffer.getvalue() +@pytest.mark.it("add ten random numbers to the list") +def test_add_random(): +assert == list + +@pytest.mark.it("print in the console the list with random numbers") +def test_output_list(): + captured = buffer.getvalue assert captured == print(list) diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index ebaef9c7..b20417e9 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1,2 +1,4 @@ #Create your here: +for i in range(1, 18): + print(i) diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index 9f2fd8e7..7d8d4032 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -3,4 +3,9 @@ sys.stdout = buffer = io.StringIO() +@pytest.mark.it("loop from 1 to 17") +def test_output_loop(): + + + From 0ab6f48b9c6b2d12aecdbb0a6fb44e2d3f3a8fe7 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 27 Aug 2019 23:21:10 +0000 Subject: [PATCH 13/92] 01 exercises readme --- exercises/01-welcome/README.md | 3 ++- exercises/02-hello-world/README.md | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/exercises/01-welcome/README.md b/exercises/01-welcome/README.md index 803a35e3..aac09713 100644 --- a/exercises/01-welcome/README.md +++ b/exercises/01-welcome/README.md @@ -1 +1,2 @@ -# Welcome to Python! \ No newline at end of file +# Welcome to Python! + diff --git a/exercises/02-hello-world/README.md b/exercises/02-hello-world/README.md index 5273e055..d0cad426 100644 --- a/exercises/02-hello-world/README.md +++ b/exercises/02-hello-world/README.md @@ -1,8 +1,11 @@ # `02` Hello World -In Python, we use `print` to make the computer write anything we want (the content of a variable, a given string, etc.) in something called "the console". +In Python, we use `print` to make the computer write anything we want (the content of a variable, a given string, etc.) +in something called `"the console".` -Every language has a console, as it was the only way to interact with the users at the beginning (before the Windows or MacOS arrived). Today, printing in the console is used mostly as a monitoring tool, ideal to leave a trace of the content of variables during the program execution. +Every language has a console, as it was the only way to interact with the users at the beginning +(before the Windows or MacOS arrived). Today, printing in the console is used mostly as a + monitoring tool, ideal to leave a trace of the content of variables during the program execution. This is an example of how to use it: ```py From 974e4b536a0173c5353231b35b5a99be1a46cdc4 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 28 Aug 2019 00:27:11 +0000 Subject: [PATCH 14/92] 05 readme and app.py --- exercises/02-hello-world/app.py | 4 ---- exercises/03-Access-and-Retrieve/app.py | 6 +++--- exercises/04-Retrieve-items/app.py | 5 +---- exercises/05-Print-the-last-one/README.md | 10 +++++----- exercises/05-Print-the-last-one/app.py | 5 +++++ exercises/05-Print-the-last-one/test.py | 19 +++++++++++++++++++ 6 files changed, 33 insertions(+), 16 deletions(-) diff --git a/exercises/02-hello-world/app.py b/exercises/02-hello-world/app.py index 47cd21e2..f881c0fb 100644 --- a/exercises/02-hello-world/app.py +++ b/exercises/02-hello-world/app.py @@ -1,8 +1,4 @@ #You have to print `hello` in the console, your code go here: -def my_function(): - return True -print("hello") - diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index 39ff0606..b8378a25 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -2,9 +2,9 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here - +print(my_list[2]) #2. change 'thursday'a value here to None - +my_list[4] = "None" #3. print the position of step 2 - +print(my_list[4]) diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 74054f88..7dcf142b 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -1,6 +1,3 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] -# print the 1st element -print(my_list[0]) -# print the 4th element -print(my_list[3]) \ No newline at end of file +#output the 1st and 4th element from the list: diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md index 6f31fff5..193ece84 100644 --- a/exercises/05-Print-the-last-one/README.md +++ b/exercises/05-Print-the-last-one/README.md @@ -1,15 +1,15 @@ # `05` Instructions from your teacher: -You will never know how many `items` myStupidArray has because it is being `randomly` generated during runtime. +You will never know how many `items` my_stupid_list has because it is being `randomly` generated during runtime. -You know that the property +You know that the property: ```js -SOMEARRAY.length +len(name_list) function ``` -returns the `length of` SOMEARRAY. +returns the `length of` name_list . ## 📝 Instructions -1. Create a variable named theLastOne, and assign it the LAST element of myStupidArray. +1. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. 2. Then, print it on the console. \ No newline at end of file diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index e69de29b..4238cd2a 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -0,0 +1,5 @@ +import random +#Feel happy to write the code below, good luck: +my_stupid_list = [] +for i in range(1, 100): + my_stupid_list.append(random.randint(1,100)) \ No newline at end of file diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index e69de29b..3461c718 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -0,0 +1,19 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + + +from app import my_stupid_list +import pytest +import random + + + +@pytest.mark.it("assign a value of my_stupid_list to the_last_one variable") +def test_assignment(): + + + + +@pytest.mark.it("print the the_last_one variable in the console") +def test_output(): From 8ad5b11fb90946ca39c9bd8e207cf70c105725fc Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 28 Aug 2019 01:46:47 +0000 Subject: [PATCH 15/92] 08 exercise --- exercises/05-Print-the-last-one/test.py | 7 ------- exercises/06-Add-item-to-list/README.md | 6 +++--- exercises/06-Add-item-to-list/app.py | 4 ++-- exercises/06-Add-item-to-list/test.py | 7 ------- exercises/07-loop-seventeen/app.py | 5 ++--- exercises/07-loop-seventeen/test.py | 6 ------ exercises/08-Loop-list/README.md | 4 ++-- exercises/08-Loop-list/app.py | 4 +++- exercises/08-Loop-list/test.py | 7 ++++++- exercises/09-Loop-from-the-top/README.md | 2 +- exercises/09-Loop-from-the-top/app.py | 3 ++- exercises/09-Loop-from-the-top/test.py | 5 +++++ 12 files changed, 26 insertions(+), 34 deletions(-) diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index 3461c718..89172e72 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -9,11 +9,4 @@ -@pytest.mark.it("assign a value of my_stupid_list to the_last_one variable") -def test_assignment(): - - - -@pytest.mark.it("print the the_last_one variable in the console") -def test_output(): diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md index 1193ade9..8312a4c9 100644 --- a/exercises/06-Add-item-to-list/README.md +++ b/exercises/06-Add-item-to-list/README.md @@ -4,9 +4,9 @@ Add 10 random integers to the "arr" list. ``` 💡Tips: -You have to import random -You can use the `random()` function to get random numbers. -Search on Google how to use random function. +1. You have to import random( function +2. Use the `random()` function to get random numbers. +3. Search on Google how to use random function. Expected in the console something similar like this: ```js diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 4d59f2da..6314e80e 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -2,6 +2,6 @@ list = [4,5,734,43,45] #Your code here: -for i in range(0, 10): - list.append(random.randint(0, 100)) +for i in range(1, 10): + list.append(random.randint(1, 100)) print(list) \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index 9fd84109..6c72e88a 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -5,11 +5,4 @@ from app import list import pytest -@pytest.mark.it("add ten random numbers to the list") -def test_add_random(): -assert == list -@pytest.mark.it("print in the console the list with random numbers") -def test_output_list(): - captured = buffer.getvalue - assert captured == print(list) diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index b20417e9..ec89829b 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1,4 +1,3 @@ -#Create your here: +#Your code here, have fun: + -for i in range(1, 18): - print(i) diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index 7d8d4032..decfea20 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -3,9 +3,3 @@ sys.stdout = buffer = io.StringIO() -@pytest.mark.it("loop from 1 to 17") -def test_output_loop(): - - - - diff --git a/exercises/08-Loop-list/README.md b/exercises/08-Loop-list/README.md index ffff8544..5a067588 100644 --- a/exercises/08-Loop-list/README.md +++ b/exercises/08-Loop-list/README.md @@ -1,13 +1,13 @@ # `08` Instructions from your teacher: -The code right now is `printing the first item in the console.` Instead of doing that, print `all the elements` in the array. +The code right now is `printing the first item in the console.` Instead of doing that, print `all the elements` in the list. ```js You will have to loop through the whole array using a loop. ``` 💡HINT 1. Remember that to access the value of a position you have to use the index -2. console.log(myArray[index]); +2. print(my_list[index]); Expected console result: ```js diff --git a/exercises/08-Loop-list/app.py b/exercises/08-Loop-list/app.py index 4c35af78..2f27c903 100644 --- a/exercises/08-Loop-list/app.py +++ b/exercises/08-Loop-list/app.py @@ -1,3 +1,5 @@ my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5] -#You don't to change nothing above, your code go below: \ No newline at end of file +#You don't to change nothing above, your code go below: +for i in range(len(my_list)): + print(my_list[i]) \ No newline at end of file diff --git a/exercises/08-Loop-list/test.py b/exercises/08-Loop-list/test.py index f2ef728f..d96f2f3c 100644 --- a/exercises/08-Loop-list/test.py +++ b/exercises/08-Loop-list/test.py @@ -5,7 +5,12 @@ from app import my_list import pytest -@pytest.mark.it("You have to print the all item from the list") +@pytest.mark.it("You have to print the all items from the list") def test_loop(): for num in my_list: print(num) + +@pytest.mark.it("other way to print the all values of my list") +def test_output(): + for x in range(len(my_list)): + print(my_list[x]) diff --git a/exercises/09-Loop-from-the-top/README.md b/exercises/09-Loop-from-the-top/README.md index 2ec6476e..6639b4e1 100644 --- a/exercises/09-Loop-from-the-top/README.md +++ b/exercises/09-Loop-from-the-top/README.md @@ -8,7 +8,7 @@ Lets try looping from the end to the beginning. 💡HINT 1. Remember the loop works like this: https://www.youtube.com/watch?v=TSMzvFwpE_A -2. The last position of the array will be mySampleArray.length - 1 because arrays start at 0 +2. The last position of the list will be variable_name[-1] because list start at 0 The console output should be something like this: diff --git a/exercises/09-Loop-from-the-top/app.py b/exercises/09-Loop-from-the-top/app.py index ad10a7dd..2ad5785b 100644 --- a/exercises/09-Loop-from-the-top/app.py +++ b/exercises/09-Loop-from-the-top/app.py @@ -1,2 +1,3 @@ my_sample_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] -#nothing change above, the magic pass below: \ No newline at end of file + +#nothing change above, the magic pass below: diff --git a/exercises/09-Loop-from-the-top/test.py b/exercises/09-Loop-from-the-top/test.py index b3162cd5..08d3942b 100644 --- a/exercises/09-Loop-from-the-top/test.py +++ b/exercises/09-Loop-from-the-top/test.py @@ -9,3 +9,8 @@ def test_loop(): for i in reversed(my_sample_list): print(i) + + +@pytest.mark.it("other way to flip list in python") +def test_print(): + print(my_sample_list[::-1]) \ No newline at end of file From 86784c1ff45a139ba0b355a8d9f5bdc188619836 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 28 Aug 2019 02:40:33 +0000 Subject: [PATCH 16/92] 11 exercise --- exercises/02-hello-world/README.md | 3 --- exercises/02-hello-world/app.py | 8 -------- exercises/05-Print-the-last-one/app.py | 4 +++- exercises/05-Print-the-last-one/test.py | 9 ++++++--- exercises/06-Add-item-to-list/app.py | 5 ++--- exercises/06-Add-item-to-list/test.py | 6 ++++++ exercises/08-Loop-list/app.py | 2 -- exercises/11-loop-from-the-half-to-the-end/README.md | 10 ++++++++++ exercises/11-loop-from-the-half-to-the-end/app.py | 0 exercises/11-loop-from-the-half-to-the-end/test.py | 0 10 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 exercises/11-loop-from-the-half-to-the-end/README.md create mode 100644 exercises/11-loop-from-the-half-to-the-end/app.py create mode 100644 exercises/11-loop-from-the-half-to-the-end/test.py diff --git a/exercises/02-hello-world/README.md b/exercises/02-hello-world/README.md index d0cad426..effa5215 100644 --- a/exercises/02-hello-world/README.md +++ b/exercises/02-hello-world/README.md @@ -18,6 +18,3 @@ print("How are you?") Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well. ``` -💡 Additional info: -5 minutes video about the console: -https://www.youtube.com/watch?v=1RlkftxAo-M \ No newline at end of file diff --git a/exercises/02-hello-world/app.py b/exercises/02-hello-world/app.py index f881c0fb..75117157 100644 --- a/exercises/02-hello-world/app.py +++ b/exercises/02-hello-world/app.py @@ -8,11 +8,3 @@ - - - -# print("hello") - -# def my_function(): -# print("Hello Inside Function") -# return True diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index 4238cd2a..e3eeb958 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -2,4 +2,6 @@ #Feel happy to write the code below, good luck: my_stupid_list = [] for i in range(1, 100): - my_stupid_list.append(random.randint(1,100)) \ No newline at end of file + my_stupid_list.append(random.randint(1,100)) + the_last_one = my_stupid_list[-1] +print(the_last_one) diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index 89172e72..7d516969 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -7,6 +7,9 @@ import pytest import random - - - +@pytest.mark.it("assignt the value and print the last one") +def test_last_one(): + my_stupid_list = [] + for i in range(1, 100): + my_stupid_list.append(random.randint(1,100)) + the_last_one = my_stupid_list[-1] diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 6314e80e..98800190 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -2,6 +2,5 @@ list = [4,5,734,43,45] #Your code here: -for i in range(1, 10): - list.append(random.randint(1, 100)) -print(list) \ No newline at end of file + + diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index 6c72e88a..8f73cfe8 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -4,5 +4,11 @@ from app import list import pytest +import random +@pytest.mark.it("add ten random number to the list") +def test_random(): + for i in range(1, 11): + list.append(random.randint(1, 10)) +print(list) diff --git a/exercises/08-Loop-list/app.py b/exercises/08-Loop-list/app.py index 2f27c903..7ffa7e6b 100644 --- a/exercises/08-Loop-list/app.py +++ b/exercises/08-Loop-list/app.py @@ -1,5 +1,3 @@ my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5] #You don't to change nothing above, your code go below: -for i in range(len(my_list)): - print(my_list[i]) \ No newline at end of file diff --git a/exercises/11-loop-from-the-half-to-the-end/README.md b/exercises/11-loop-from-the-half-to-the-end/README.md new file mode 100644 index 00000000..46ff0af3 --- /dev/null +++ b/exercises/11-loop-from-the-half-to-the-end/README.md @@ -0,0 +1,10 @@ + +# `11` Instructions from your teacher: + +This loop is not looping at all... because the variables initialValue, stopValue and increasingValue are equal to zero. + +Instructions +Change the value of those variables to make the loop print only the last half of the array. +Change nothing but the value of those 3 variables! + +The result should be something like: \ No newline at end of file diff --git a/exercises/11-loop-from-the-half-to-the-end/app.py b/exercises/11-loop-from-the-half-to-the-end/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/11-loop-from-the-half-to-the-end/test.py b/exercises/11-loop-from-the-half-to-the-end/test.py new file mode 100644 index 00000000..e69de29b From 6a52d57d67e67ea01d0cfebe7df8d9ccc7487526 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 15:57:48 +0000 Subject: [PATCH 17/92] app.py 05 --- exercises/03-Access-and-Retrieve/app.py | 6 +++--- exercises/05-Print-the-last-one/app.py | 1 + exercises/05-Print-the-last-one/test.py | 4 ---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/03-Access-and-Retrieve/app.py index b8378a25..39ff0606 100644 --- a/exercises/03-Access-and-Retrieve/app.py +++ b/exercises/03-Access-and-Retrieve/app.py @@ -2,9 +2,9 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_list[2]) + #2. change 'thursday'a value here to None -my_list[4] = "None" + #3. print the position of step 2 -print(my_list[4]) + diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index e3eeb958..12fadba5 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -1,3 +1,4 @@ +#You have to import random function: import random #Feel happy to write the code below, good luck: my_stupid_list = [] diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index 7d516969..5813e515 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -9,7 +9,3 @@ @pytest.mark.it("assignt the value and print the last one") def test_last_one(): - my_stupid_list = [] - for i in range(1, 100): - my_stupid_list.append(random.randint(1,100)) - the_last_one = my_stupid_list[-1] From 197c627c7a08c486acd3ad1e838d6a0eaf6f45d4 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 16:18:14 +0000 Subject: [PATCH 18/92] def function assign random number --- exercises/05-Print-the-last-one/app.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index 12fadba5..ebe8f2ac 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -1,8 +1,24 @@ #You have to import random function: import random #Feel happy to write the code below, good luck: -my_stupid_list = [] -for i in range(1, 100): - my_stupid_list.append(random.randint(1,100)) - the_last_one = my_stupid_list[-1] + +def generate_random_list(): + aux_list = [] + randonlength = random.randint(1, 100) + + for i in range(randonlength): + aux_list.append(randonlength) + i += i + return aux_list + +my_stupid_list = generate_random_list() +the_last_one = my_stupid_list[-1] + print(the_last_one) + + +# my_stupid_list = [] +# for i in range(1, 100): +# my_stupid_list.append(random.randint(1,100)) +# the_last_one = my_stupid_list[-1] +# print(the_last_one) \ No newline at end of file From 298deb2fa3957b1329a4885328cbc2694d386ae7 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 16:22:56 +0000 Subject: [PATCH 19/92] add random number to the list --- exercises/06-Add-item-to-list/app.py | 5 ++++- exercises/06-Add-item-to-list/test.py | 4 +--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 98800190..75c778a8 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,6 +1,9 @@ +#Remember import random function here: import random list = [4,5,734,43,45] #Your code here: - +for i in range(1, 11): + list.append(random.randint(1, 10)) +print(list) diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index 8f73cfe8..8f041a13 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -9,6 +9,4 @@ @pytest.mark.it("add ten random number to the list") def test_random(): - for i in range(1, 11): - list.append(random.randint(1, 10)) -print(list) + From 37535f236f6764ce4c4fc7f56d58597c921c9a42 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 16:28:07 +0000 Subject: [PATCH 20/92] print the las random number --- exercises/04-Retrieve-items/app.py | 2 ++ exercises/05-Print-the-last-one/README.md | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 7dcf142b..27ec6512 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -1,3 +1,5 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] #output the 1st and 4th element from the list: +print(my_list[0]) +print(my_list[3]) diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md index 193ece84..1a41bf1f 100644 --- a/exercises/05-Print-the-last-one/README.md +++ b/exercises/05-Print-the-last-one/README.md @@ -10,6 +10,6 @@ len(name_list) function returns the `length of` name_list . ## 📝 Instructions - -1. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. -2. Then, print it on the console. \ No newline at end of file +1. First you have to `import random` function +2. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. +3. Then, print it on the console. \ No newline at end of file From b307bf1eb627807d032dda27e154bc80057450c1 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 16:32:55 +0000 Subject: [PATCH 21/92] loop form 1 to 17 --- exercises/05-Print-the-last-one/README.md | 8 +++++--- exercises/06-Add-item-to-list/README.md | 2 +- exercises/07-loop-seventeen/app.py | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md index 1a41bf1f..37579d16 100644 --- a/exercises/05-Print-the-last-one/README.md +++ b/exercises/05-Print-the-last-one/README.md @@ -10,6 +10,8 @@ len(name_list) function returns the `length of` name_list . ## 📝 Instructions -1. First you have to `import random` function -2. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. -3. Then, print it on the console. \ No newline at end of file +1. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. +2. Then, print it on the console. + +💡Hint: +`Remember import random function` \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md index 8312a4c9..b2dc2e98 100644 --- a/exercises/06-Add-item-to-list/README.md +++ b/exercises/06-Add-item-to-list/README.md @@ -4,7 +4,7 @@ Add 10 random integers to the "arr" list. ``` 💡Tips: -1. You have to import random( function +1. You have to `import random` function 2. Use the `random()` function to get random numbers. 3. Search on Google how to use random function. diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index ec89829b..f65f0162 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1,3 +1,4 @@ #Your code here, have fun: - +for i in range(1, 18): + print(i) From df7c9436e5f148415a40944341bbd4c1fb093ab4 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 17:13:20 +0000 Subject: [PATCH 22/92] print the all values of the list looping --- exercises/07-loop-seventeen/README.md | 4 +++- exercises/08-Loop-list/README.md | 2 +- exercises/08-Loop-list/app.py | 9 +++++++++ exercises/08-Loop-list/test.py | 8 -------- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/exercises/07-loop-seventeen/README.md b/exercises/07-loop-seventeen/README.md index b087c413..20b9ee24 100644 --- a/exercises/07-loop-seventeen/README.md +++ b/exercises/07-loop-seventeen/README.md @@ -4,8 +4,10 @@ Count from 1 to 17 with a loop and print each number on the console. ``` + 💡HINT: -You have to loop from 1 to 17. +1. This how you loop +`https://www.w3schools.com/python/python_for_loops.asp` Expected console result: ```js diff --git a/exercises/08-Loop-list/README.md b/exercises/08-Loop-list/README.md index 5a067588..308e1a03 100644 --- a/exercises/08-Loop-list/README.md +++ b/exercises/08-Loop-list/README.md @@ -2,7 +2,7 @@ The code right now is `printing the first item in the console.` Instead of doing that, print `all the elements` in the list. ```js -You will have to loop through the whole array using a loop. +You will have to loop through the whole array using a for loop. ``` 💡HINT diff --git a/exercises/08-Loop-list/app.py b/exercises/08-Loop-list/app.py index 7ffa7e6b..692281ea 100644 --- a/exercises/08-Loop-list/app.py +++ b/exercises/08-Loop-list/app.py @@ -1,3 +1,12 @@ my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5] #You don't to change nothing above, your code go below: + +print(my_list[0]) + + + + + +#for i in range(len(my_list)): +# print(my_list[i]) \ No newline at end of file diff --git a/exercises/08-Loop-list/test.py b/exercises/08-Loop-list/test.py index d96f2f3c..9e119350 100644 --- a/exercises/08-Loop-list/test.py +++ b/exercises/08-Loop-list/test.py @@ -5,12 +5,4 @@ from app import my_list import pytest -@pytest.mark.it("You have to print the all items from the list") -def test_loop(): - for num in my_list: - print(num) -@pytest.mark.it("other way to print the all values of my list") -def test_output(): - for x in range(len(my_list)): - print(my_list[x]) From fe0b7287104f393c19d2b6ed9cc224b083bfc0ed Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 17:26:49 +0000 Subject: [PATCH 23/92] flip list --- exercises/09-Loop-from-the-top/app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/exercises/09-Loop-from-the-top/app.py b/exercises/09-Loop-from-the-top/app.py index 2ad5785b..1741efa4 100644 --- a/exercises/09-Loop-from-the-top/app.py +++ b/exercises/09-Loop-from-the-top/app.py @@ -1,3 +1,12 @@ my_sample_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] #nothing change above, the magic pass below: + + +for i in range(len(my_sample_list)): + print(my_sample_list[-i-1]) + + +for i in reversed(my_sample_list): + print(i) + From e74ad3bc8abd6a721717c01c7c715ab723e5fb03 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 17:38:55 +0000 Subject: [PATCH 24/92] looping 2 by 2 --- exercises/09-Loop-from-the-top/test.py | 10 ---------- exercises/10-Loop-adding-two/app.py | 10 +++++++++- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/exercises/09-Loop-from-the-top/test.py b/exercises/09-Loop-from-the-top/test.py index 08d3942b..07b99521 100644 --- a/exercises/09-Loop-from-the-top/test.py +++ b/exercises/09-Loop-from-the-top/test.py @@ -4,13 +4,3 @@ from app import my_sample_list import pytest - -@pytest.mark.it('Try looping from the end to the beginning') -def test_loop(): - for i in reversed(my_sample_list): - print(i) - - -@pytest.mark.it("other way to flip list in python") -def test_print(): - print(my_sample_list[::-1]) \ No newline at end of file diff --git a/exercises/10-Loop-adding-two/app.py b/exercises/10-Loop-adding-two/app.py index 3bd5a361..f328c488 100644 --- a/exercises/10-Loop-adding-two/app.py +++ b/exercises/10-Loop-adding-two/app.py @@ -1,3 +1,11 @@ my_sample_list= [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] -#your code go below of this line, nothing change above: \ No newline at end of file +#your code go below of this line, nothing change above: + + +for i in range(0, len(my_sample_list), 2): + print(my_sample_list[i]) + + +for i in my_sample_list[0::2]: + print(i) \ No newline at end of file From dc10b0764590153bb3a8d6b5790cb40aa5fd4d09 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 18:11:01 +0000 Subject: [PATCH 25/92] lopping from half to end --- exercises/10-Loop-adding-two/test.py | 3 +-- exercises/11-loop-from-the-half-to-the-end/app.py | 11 +++++++++++ exercises/11-loop-from-the-half-to-the-end/test.py | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/exercises/10-Loop-adding-two/test.py b/exercises/10-Loop-adding-two/test.py index 5cb55e0e..794503d8 100644 --- a/exercises/10-Loop-adding-two/test.py +++ b/exercises/10-Loop-adding-two/test.py @@ -5,5 +5,4 @@ from app import my_sample_list import pytest -@pytest.mark.it("loop two by two") -def test_loop(): + diff --git a/exercises/11-loop-from-the-half-to-the-end/app.py b/exercises/11-loop-from-the-half-to-the-end/app.py index e69de29b..9dd8c0fc 100644 --- a/exercises/11-loop-from-the-half-to-the-end/app.py +++ b/exercises/11-loop-from-the-half-to-the-end/app.py @@ -0,0 +1,11 @@ +my_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] +#Your code here: + +inicialValue = 0 +stopValue = 0 +increaseValue = 0 + +for i in range(inicialValue, stopValue): + if i == my_list[i]: + i += increaseValue + print(my_list[i]) \ No newline at end of file diff --git a/exercises/11-loop-from-the-half-to-the-end/test.py b/exercises/11-loop-from-the-half-to-the-end/test.py index e69de29b..0aba17d1 100644 --- a/exercises/11-loop-from-the-half-to-the-end/test.py +++ b/exercises/11-loop-from-the-half-to-the-end/test.py @@ -0,0 +1 @@ +import os \ No newline at end of file From 6ef9122756524a24acea0b0abedd2c60822cc33d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 19:36:32 +0000 Subject: [PATCH 26/92] change value, set value, reversed list --- exercises/12-One_last_looping/README.md | 23 +++++++++++++++++++++++ exercises/12-One_last_looping/app.py | 17 +++++++++++++++++ exercises/12-One_last_looping/test.py | 0 3 files changed, 40 insertions(+) create mode 100644 exercises/12-One_last_looping/README.md create mode 100644 exercises/12-One_last_looping/app.py create mode 100644 exercises/12-One_last_looping/test.py diff --git a/exercises/12-One_last_looping/README.md b/exercises/12-One_last_looping/README.md new file mode 100644 index 00000000..c4eff82c --- /dev/null +++ b/exercises/12-One_last_looping/README.md @@ -0,0 +1,23 @@ +#`12` Instructions from your teacher: +1. Change the second item value to 'Steven' +2. Set the last position to 'Pepe' +3. Set the first element to the value of the 3rd element concatenated to the value of the 5th element. +4. Reverse loop (from the end to the beginning) the whole array and print all the elements. + +💡HINT: +1. Remember that list start at position 0. + +The result should be something like this: +```js +Pepe +Bart +Cesco +Fernando +Lou +Maria +Pedro +Lebron +Ruth +Steven +RuthPedro +``` \ No newline at end of file diff --git a/exercises/12-One_last_looping/app.py b/exercises/12-One_last_looping/app.py new file mode 100644 index 00000000..23f797a7 --- /dev/null +++ b/exercises/12-One_last_looping/app.py @@ -0,0 +1,17 @@ +my_sample_list = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie'] + +#Your code here: + +my_sample_list[1] == "Steve" +my_sample_list[-1] == "Pepe" +my_sample_list[0] == my_sample_list[2] + my_sample_list[4] + + +for i in reversed(my_sample_list): + print(i) + + +new_list = [] +for i in range(len(my_sample_list)): + new_list.append(my_sample_list[-i-1]) +print(new_list) \ No newline at end of file diff --git a/exercises/12-One_last_looping/test.py b/exercises/12-One_last_looping/test.py new file mode 100644 index 00000000..e69de29b From dabba920cc0e28757754c872e6de8ab1d949506c Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 20:15:39 +0000 Subject: [PATCH 27/92] finding position from the list --- exercises/13-Finding_wally/README.md | 17 +++++++++++++++++ exercises/13-Finding_wally/app.py | 9 +++++++++ exercises/13-Finding_wally/test.py | 0 3 files changed, 26 insertions(+) create mode 100644 exercises/13-Finding_wally/README.md create mode 100644 exercises/13-Finding_wally/app.py create mode 100644 exercises/13-Finding_wally/test.py diff --git a/exercises/13-Finding_wally/README.md b/exercises/13-Finding_wally/README.md new file mode 100644 index 00000000..0be4fffd --- /dev/null +++ b/exercises/13-Finding_wally/README.md @@ -0,0 +1,17 @@ +# `13` Instructions from your teacher: +1. Find Wally :) +2. Print the position(s) of Wally in the console. + +📝Hint +USE A `LOOP!!!` and an `IF (conditional)` + + +Easter Egg: +What if there is more than one Wally? + + +The console output expected: +```js +65 +198 +``` \ No newline at end of file diff --git a/exercises/13-Finding_wally/app.py b/exercises/13-Finding_wally/app.py new file mode 100644 index 00000000..2b90156f --- /dev/null +++ b/exercises/13-Finding_wally/app.py @@ -0,0 +1,9 @@ +people = [ 'Lebron','Aaliyah','Diamond','Dominique','Aliyah','Jazmin','Darnell','Hatfield','Hawkins','Hayden','Hayes','Haynes','Hays','Head','Heath','Hebert','Henderson','Hendricks','Hendrix','Henry','Hensley','Henson','Herman','Hernandez','Herrera','Herring','Hess','Hester','Hewitt','Hickman','Hicks','Higgins','Hill','Hines','Hinton','Hobbs','Hodge','Hodges','Hoffman','Hogan','Holcomb','Holden','Holder','Holland','Holloway','Holman','Holmes','Holt','Hood','Hooper','Hoover','Hopkins','Hopper','Horn','Horne','Horton','House','Houston','Howard','Howe','Howell','Hubbard','Huber','Hudson','Huff','Wally','Hughes','Hull','Humphrey','Hunt','Hunter','Hurley','Hurst','Hutchinson','Hyde','Ingram','Irwin','Jackson','Jacobs','Jacobson','James','Jarvis','Jefferson','Jenkins','Jennings','Jensen','Jimenez','Johns','Johnson','Johnston','Jones','Jordan','Joseph','Joyce','Joyner','Juarez','Justice','Kane','Kaufman','Keith','Keller','Kelley','Kelly','Kemp','Kennedy','Kent','Kerr','Key','Kidd','Kim','King','Kinney','Kirby','Kirk','Kirkland','Klein','Kline','Knapp','Knight','Knowles','Knox','Koch','Kramer','Lamb','Lambert','Lancaster','Landry','Lane','Lang','Langley','Lara','Larsen','Larson','Lawrence','Lawson','Le','Leach','Leblanc','Lee','Leon','Leonard','Lester','Levine','Levy','Lewis','Lindsay','Lindsey','Little','Livingston','Lloyd','Logan','Long','Lopez','Lott','Love','Lowe','Lowery','Lucas','Luna','Lynch','Lynn','Lyons','Macdonald','Macias','Mack','Madden','Maddox','Maldonado','Malone','Mann','Manning','Marks','Marquez','Marsh','Marshall','Martin','Martinez','Mason','Massey','Mathews','Mathis','Matthews','Maxwell','May','Mayer','Maynard','Mayo','Mays','Mcbride','Mccall','Mccarthy','Mccarty','Mcclain','Mcclure','Mcconnell','Mccormick','Mccoy','Mccray','Wally','Mcdaniel','Mcdonald','Mcdowell','Mcfadden','Mcfarland','Mcgee','Mcgowan','Mcguire','Mcintosh','Mcintyre','Mckay','Mckee','Mckenzie','Mckinney','Mcknight','Mclaughlin','Mclean','Mcleod','Mcmahon','Mcmillan','Mcneil','Mcpherson','Meadows','Medina','Mejia','Melendez','Melton','Mendez','Mendoza','Mercado','Mercer','Merrill','Merritt','Meyer','Meyers','Michael','Middleton','Miles','Miller','Mills','Miranda','Mitchell','Molina','Monroe','Lucas','Jake','Scott','Amy','Molly','Hannah','Lucas'] + +#Your code here: + +position = [] +for i in range(0, len(people)): + if people[i] == "Wally": + position.append(i) +print(position) diff --git a/exercises/13-Finding_wally/test.py b/exercises/13-Finding_wally/test.py new file mode 100644 index 00000000..e69de29b From 45edd222e0a2c836cd0375d3ce49fc3223496b40 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 20:43:09 +0000 Subject: [PATCH 28/92] readme counter letter --- exercises/13-Finding_wally/app.py | 5 +++++ exercises/14-letter_counter/RAEDME.md | 19 +++++++++++++++++++ exercises/14-letter_counter/app.py | 0 exercises/14-letter_counter/test.py | 0 4 files changed, 24 insertions(+) create mode 100644 exercises/14-letter_counter/RAEDME.md create mode 100644 exercises/14-letter_counter/app.py create mode 100644 exercises/14-letter_counter/test.py diff --git a/exercises/13-Finding_wally/app.py b/exercises/13-Finding_wally/app.py index 2b90156f..a37837a3 100644 --- a/exercises/13-Finding_wally/app.py +++ b/exercises/13-Finding_wally/app.py @@ -7,3 +7,8 @@ if people[i] == "Wally": position.append(i) print(position) + +#i thing is the second one +for i in range(len(people)): + if people[i] == "Wally": + print(i) \ No newline at end of file diff --git a/exercises/14-letter_counter/RAEDME.md b/exercises/14-letter_counter/RAEDME.md new file mode 100644 index 00000000..14969db6 --- /dev/null +++ b/exercises/14-letter_counter/RAEDME.md @@ -0,0 +1,19 @@ +# `14` Instructions from your teacher: + +```js +Letter Counter +Our customer needs a program that counts the letters repetitions in a given string, +I know that's weird, but they are very adamant, We need this asap! +``` + +📝Instructions: +1. letters and the values are the number of times it is repeated throughout the string. + +Example +print(count()); + +//will print on the console { h: 1, e: 1, l: 2, o: 1 } + +💡Hints: +Ignore white spaces in the string. +you should lower case all letters to have an accurate count of all letters regardless of casing of the letter. \ No newline at end of file diff --git a/exercises/14-letter_counter/app.py b/exercises/14-letter_counter/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/14-letter_counter/test.py b/exercises/14-letter_counter/test.py new file mode 100644 index 00000000..e69de29b From e904e75b408896c335e25e156d0b01c25d3debc1 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 23:34:43 +0000 Subject: [PATCH 29/92] counter letter --- exercises/14-letter_counter/app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/exercises/14-letter_counter/app.py b/exercises/14-letter_counter/app.py index e69de29b..ad637919 100644 --- a/exercises/14-letter_counter/app.py +++ b/exercises/14-letter_counter/app.py @@ -0,0 +1,18 @@ +par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus" + +#Your code go here: + +count = {} +for i in par: + if i in count: + count[i] += 1 + else: + count[i] = 1 +print(count) + + +letter = {} +for i in par: + letter = letter.get(i, 0) + 1 + +print(letter) \ No newline at end of file From 2cdf18ffcecdf364a1f46649035ff167c8b504fc Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 2 Sep 2019 23:42:02 +0000 Subject: [PATCH 30/92] readme 15 --- exercises/15-flip_list/README.md | 12 ++++++++++++ exercises/15-flip_list/app.py | 0 exercises/15-flip_list/test.py | 0 3 files changed, 12 insertions(+) create mode 100644 exercises/15-flip_list/README.md create mode 100644 exercises/15-flip_list/app.py create mode 100644 exercises/15-flip_list/test.py diff --git a/exercises/15-flip_list/README.md b/exercises/15-flip_list/README.md new file mode 100644 index 00000000..cec0b7f1 --- /dev/null +++ b/exercises/15-flip_list/README.md @@ -0,0 +1,12 @@ +# `15` Instructions from your teacher: + +Using a loop, invert the "arr" list. + +```js +Initial list: [45, 67, 87, 23, 5, 32, 60] +Final list: [60, 32, 5 , 23, 87, 67, 45] +``` + + +💡Hint +You should loop the entire list, and push all the items (as you go) into a new list. \ No newline at end of file diff --git a/exercises/15-flip_list/app.py b/exercises/15-flip_list/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/15-flip_list/test.py b/exercises/15-flip_list/test.py new file mode 100644 index 00000000..e69de29b From a3b543719df73097fb4abed64875187295f94062 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 3 Sep 2019 03:21:22 +0000 Subject: [PATCH 31/92] flip list --- exercises/15-flip_list/app.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/exercises/15-flip_list/app.py b/exercises/15-flip_list/app.py index e69de29b..82291217 100644 --- a/exercises/15-flip_list/app.py +++ b/exercises/15-flip_list/app.py @@ -0,0 +1,10 @@ +arr = [45, 67, 87, 23, 5, 32, 60] + +#your code below: + +for i in range(len(arr)): + print(arr[-(i+1)]) + + +for i in range(len(arr)): + print(arr[-i-1]) \ No newline at end of file From cfb368763e8cbfe43ec90d2fa0f269cb865cef4f Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 3 Sep 2019 03:57:53 +0000 Subject: [PATCH 32/92] type of valie --- exercises/16-mixed_list/README.md | 19 +++++++++++++++++++ exercises/16-mixed_list/app.py | 8 ++++++++ exercises/16-mixed_list/test.py | 0 3 files changed, 27 insertions(+) create mode 100644 exercises/16-mixed_list/README.md create mode 100644 exercises/16-mixed_list/app.py create mode 100644 exercises/16-mixed_list/test.py diff --git a/exercises/16-mixed_list/README.md b/exercises/16-mixed_list/README.md new file mode 100644 index 00000000..8c64f391 --- /dev/null +++ b/exercises/16-mixed_list/README.md @@ -0,0 +1,19 @@ +# `16` Instructions from your teacher: + +1. Write a function to programmatically print in the console the +types of the values that the list contains in each position. + +```js +The console must have something like this: +``` + +number +boolean +string +object +string +number +object + +💡Hint: +You can use the type() python function. \ No newline at end of file diff --git a/exercises/16-mixed_list/app.py b/exercises/16-mixed_list/app.py new file mode 100644 index 00000000..43ba548b --- /dev/null +++ b/exercises/16-mixed_list/app.py @@ -0,0 +1,8 @@ +mix = [42, 'true', "towel", [2,1], 'hello', 34.4, {"name": "juan"}] + +# Your code below: + +for i in range(len(mix)): + if mix[i] == i: + i += 1 + print(type(mix[i])) diff --git a/exercises/16-mixed_list/test.py b/exercises/16-mixed_list/test.py new file mode 100644 index 00000000..e69de29b From d91cb00fbf8761b1c4ffe6954aa035b74b6eacc3 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 3 Sep 2019 04:16:44 +0000 Subject: [PATCH 33/92] readme 17 --- exercises/16-mixed_list/app.py | 5 +++++ exercises/17-count_on/README.md | 19 +++++++++++++++++++ exercises/17-count_on/app.py | 1 + exercises/17-count_on/test.py | 0 4 files changed, 25 insertions(+) create mode 100644 exercises/17-count_on/README.md create mode 100644 exercises/17-count_on/app.py create mode 100644 exercises/17-count_on/test.py diff --git a/exercises/16-mixed_list/app.py b/exercises/16-mixed_list/app.py index 43ba548b..dc43d25f 100644 --- a/exercises/16-mixed_list/app.py +++ b/exercises/16-mixed_list/app.py @@ -6,3 +6,8 @@ if mix[i] == i: i += 1 print(type(mix[i])) + + +for i in range(len(mix)): + item = mix[i] + print(type(item)) \ No newline at end of file diff --git a/exercises/17-count_on/README.md b/exercises/17-count_on/README.md new file mode 100644 index 00000000..77c657f4 --- /dev/null +++ b/exercises/17-count_on/README.md @@ -0,0 +1,19 @@ +# `17` Instructions from your teacher: +`Count On` +As you saw in the last exercise your list can be a mix `types of data` we are going to divide and conquer. + +Would you be so kind to add all the items with data-type object into the hello list? + +💡Hint: +Here is how to print ALL the items. +my_list = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] + +for i in range(len(mix)): + item = mix[i] + print(type(item)) + + +# Instructions +1. Loop the given array +2. Push the arrays found to an new array called hello +3. Console log the variable hello diff --git a/exercises/17-count_on/app.py b/exercises/17-count_on/app.py new file mode 100644 index 00000000..70e011d2 --- /dev/null +++ b/exercises/17-count_on/app.py @@ -0,0 +1 @@ +my_list = [42, 'true', "towel", [2,1], 'hello', 34.4, {"name": "juan"}] diff --git a/exercises/17-count_on/test.py b/exercises/17-count_on/test.py new file mode 100644 index 00000000..e69de29b From 36c0b2b7bd90252eadc70a8f6cfedca2059edfe6 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 00:42:25 +0000 Subject: [PATCH 34/92] sum the all values from the list --- exercises/16-mixed_list/app.py | 2 +- exercises/17-count_on/app.py | 4 +++- exercises/18-Sum_all_items/README.md | 10 ++++++++++ exercises/18-Sum_all_items/app.py | 22 ++++++++++++++++++++++ exercises/18-Sum_all_items/test.py | 0 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 exercises/18-Sum_all_items/README.md create mode 100644 exercises/18-Sum_all_items/app.py create mode 100644 exercises/18-Sum_all_items/test.py diff --git a/exercises/16-mixed_list/app.py b/exercises/16-mixed_list/app.py index dc43d25f..ece2db7a 100644 --- a/exercises/16-mixed_list/app.py +++ b/exercises/16-mixed_list/app.py @@ -1,4 +1,4 @@ -mix = [42, 'true', "towel", [2,1], 'hello', 34.4, {"name": "juan"}] +mix = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] # Your code below: diff --git a/exercises/17-count_on/app.py b/exercises/17-count_on/app.py index 70e011d2..4ee3e919 100644 --- a/exercises/17-count_on/app.py +++ b/exercises/17-count_on/app.py @@ -1 +1,3 @@ -my_list = [42, 'true', "towel", [2,1], 'hello', 34.4, {"name": "juan"}] +my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] + +#your code go here: \ No newline at end of file diff --git a/exercises/18-Sum_all_items/README.md b/exercises/18-Sum_all_items/README.md new file mode 100644 index 00000000..4a3105fa --- /dev/null +++ b/exercises/18-Sum_all_items/README.md @@ -0,0 +1,10 @@ + +# `18` Instructions from your teacher: + +1. Complete the code of the function "sum" so that it returns the sum of all the items in my_sample_list. +```js +The result should be 925960 +``` + +💡Hint: +You have to `loop the entire list` and add the value of each item into the "total" variable. \ No newline at end of file diff --git a/exercises/18-Sum_all_items/app.py b/exercises/18-Sum_all_items/app.py new file mode 100644 index 00000000..1ba9ba33 --- /dev/null +++ b/exercises/18-Sum_all_items/app.py @@ -0,0 +1,22 @@ +my_sample_list = [3423,5,4,47889,654,8,867543,23,48,5345,234,6,78,54,23,67,3,6,432,55,23,25,12] + + +def sum_all_values(items): + + total = 0 + #The magic happens here: + + # for i in range(len(items)): + # total += items[i] + + return total +print(sum_all_values(my_sample_list)) + + + +def other(items): + total = 0 + for i in items: + total += i + return total +print(other(my_sample_list)) \ No newline at end of file diff --git a/exercises/18-Sum_all_items/test.py b/exercises/18-Sum_all_items/test.py new file mode 100644 index 00000000..e69de29b From b805af3968ff1eed0071f1bfff7beb0ecc9a45ad Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 00:48:20 +0000 Subject: [PATCH 35/92] readme of 19 exercise --- exercises/19-sum_odd_items/README.md | 15 +++++++++++++++ exercises/19-sum_odd_items/app.py | 0 exercises/19-sum_odd_items/test.py | 0 3 files changed, 15 insertions(+) create mode 100644 exercises/19-sum_odd_items/README.md create mode 100644 exercises/19-sum_odd_items/app.py create mode 100644 exercises/19-sum_odd_items/test.py diff --git a/exercises/19-sum_odd_items/README.md b/exercises/19-sum_odd_items/README.md new file mode 100644 index 00000000..e921985d --- /dev/null +++ b/exercises/19-sum_odd_items/README.md @@ -0,0 +1,15 @@ +# `19` +# 📝Instructions from your teacher: + +1. Create a function called sumOdds that sums all the odd numbers in the "arr" +2. list and returns the result. + +# To do this exercise consider: +- You have to `loop the list`. +- You will need to `declare an auxiliar variable outside the loop` to keep adding the values. +- On each loop, you have to `ask if the value of the list in that index position is an odd number`. +- If its odd then add the value to the `auxiliar`. + +💡Hint: an auxiliar variable is a regular variable, the only difference is a logical difference; an +auxiliar variable is like a chosen one, it'll be useful until it completes its purpose (add all the values, +make a copy of a value, etc). \ No newline at end of file diff --git a/exercises/19-sum_odd_items/app.py b/exercises/19-sum_odd_items/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/19-sum_odd_items/test.py b/exercises/19-sum_odd_items/test.py new file mode 100644 index 00000000..e69de29b From ab5a34920363f8bac97666a2d66fc809521db06d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 00:57:27 +0000 Subject: [PATCH 36/92] sum odd items from the list --- exercises/19-sum_odd_items/app.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exercises/19-sum_odd_items/app.py b/exercises/19-sum_odd_items/app.py index e69de29b..65e33566 100644 --- a/exercises/19-sum_odd_items/app.py +++ b/exercises/19-sum_odd_items/app.py @@ -0,0 +1,12 @@ +arr = [4,5,734,43,45,100,4,56,23,67,23,58,45] + +#Your code go here: + +def sumOdd(items): + aux = 0 + + for i in arr: + if i % 2 != 0: + aux += i + return aux +print(sumOdd(arr)) \ No newline at end of file From 33eb78dc19d2b2905e1ad32132c9f194dcb1bf74 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 01:49:32 +0000 Subject: [PATCH 37/92] conditional examples --- exercises/19-sum_odd_items/app.py | 1 - exercises/20-forEach_loop/README.md | 18 +++++++++++++++++ exercises/20-forEach_loop/app.py | 3 +++ exercises/20-forEach_loop/test.py | 0 exercises/21-Everything_is_awesome/README.md | 16 +++++++++++++++ exercises/21-Everything_is_awesome/app.py | 21 ++++++++++++++++++++ exercises/21-Everything_is_awesome/test.py | 0 7 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 exercises/20-forEach_loop/README.md create mode 100644 exercises/20-forEach_loop/app.py create mode 100644 exercises/20-forEach_loop/test.py create mode 100644 exercises/21-Everything_is_awesome/README.md create mode 100644 exercises/21-Everything_is_awesome/app.py create mode 100644 exercises/21-Everything_is_awesome/test.py diff --git a/exercises/19-sum_odd_items/app.py b/exercises/19-sum_odd_items/app.py index 65e33566..2968b487 100644 --- a/exercises/19-sum_odd_items/app.py +++ b/exercises/19-sum_odd_items/app.py @@ -4,7 +4,6 @@ def sumOdd(items): aux = 0 - for i in arr: if i % 2 != 0: aux += i diff --git a/exercises/20-forEach_loop/README.md b/exercises/20-forEach_loop/README.md new file mode 100644 index 00000000..55431a8b --- /dev/null +++ b/exercises/20-forEach_loop/README.md @@ -0,0 +1,18 @@ +# `20` +It is possible to traverse an list using the list.forEach function. +You have to specify what to do on each iteration of the loop. +```js +//item will be the value of the specific item. +//index will be the item index. +//arr will be the +my_list.forEach(function(item, index, arr){ + +}); +``` + +# 📝Instructions +Right now, the code is printing all the items in the list: + 1. Please change the function code to print only the numbers `divisible by 14`. + +💡HINT +`A number X is divisible by 2 if: (X%2===0)` \ No newline at end of file diff --git a/exercises/20-forEach_loop/app.py b/exercises/20-forEach_loop/app.py new file mode 100644 index 00000000..45ee11de --- /dev/null +++ b/exercises/20-forEach_loop/app.py @@ -0,0 +1,3 @@ +my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] + + diff --git a/exercises/20-forEach_loop/test.py b/exercises/20-forEach_loop/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/21-Everything_is_awesome/README.md b/exercises/21-Everything_is_awesome/README.md new file mode 100644 index 00000000..ef8572b7 --- /dev/null +++ b/exercises/21-Everything_is_awesome/README.md @@ -0,0 +1,16 @@ +# `21` + +# Instructions from your teacher: + +1. Compare the item if it is 1 push the number to the list return_list +2. Compare the item if it is 0 push "Yahoo" to the list return_list (instead of the number) + +```js +Example output for [0,0,1,1,0]: + +Yahoo, +Yahoo, +1, +1, +Yahoo +``` \ No newline at end of file diff --git a/exercises/21-Everything_is_awesome/app.py b/exercises/21-Everything_is_awesome/app.py new file mode 100644 index 00000000..910482bb --- /dev/null +++ b/exercises/21-Everything_is_awesome/app.py @@ -0,0 +1,21 @@ +my_list = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ] + +def sample(items): + return_list = [] + for i in items: + #the magic happens here: + + return return_list +print(sample(my_list)) + + +# def sample(items): +# return_list = [] +# for i in items: +# if i == 1: +# return_list.append(i) +# elif i == 0: +# return_list.append("Yahoo") + +# return return_list +# print(sample(my_list)) \ No newline at end of file diff --git a/exercises/21-Everything_is_awesome/test.py b/exercises/21-Everything_is_awesome/test.py new file mode 100644 index 00000000..e69de29b From 28d581224f4143c452cc1aede40ce265eff48cae Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 02:02:35 +0000 Subject: [PATCH 38/92] readme 22 --- exercises/22-Dowhile_DO_DO/README.md | 41 ++++++++++++++++++++++++++++ exercises/22-Dowhile_DO_DO/app.py | 0 exercises/22-Dowhile_DO_DO/test.py | 0 3 files changed, 41 insertions(+) create mode 100644 exercises/22-Dowhile_DO_DO/README.md create mode 100644 exercises/22-Dowhile_DO_DO/app.py create mode 100644 exercises/22-Dowhile_DO_DO/test.py diff --git a/exercises/22-Dowhile_DO_DO/README.md b/exercises/22-Dowhile_DO_DO/README.md new file mode 100644 index 00000000..2931ca6d --- /dev/null +++ b/exercises/22-Dowhile_DO_DO/README.md @@ -0,0 +1,41 @@ +# `22` + +# Instructions from your teacher: +DO DO DO +The do{}while(); is another loop example in python is less commonly used but it is a loop +// stating value for the loop +let i = 0; + +// the loop will do everything inside of the do code block +do { + // print out the i value + print(i) + // increase the i value + i++ + // evaluate the value +} while (i < 5); + + +#📝Instructions +1. Print every iteration number on the console from 20 to 0, + but `concatenate an exclamation point` to the output if the number + is a module of 5 +2. At the end print() "LIFTOFF" + +```js +Example Output on the console: +20! +19 +18 +17 +16 +15! +14 +13 +12 +11 +10! +. +. +LIFTOFF +``` \ No newline at end of file diff --git a/exercises/22-Dowhile_DO_DO/app.py b/exercises/22-Dowhile_DO_DO/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/22-Dowhile_DO_DO/test.py b/exercises/22-Dowhile_DO_DO/test.py new file mode 100644 index 00000000..e69de29b From c68311e3e21b533d40718f5cbe50571748860943 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 04:22:29 +0000 Subject: [PATCH 39/92] merge list function --- exercises/23-Delete_element/README.md | 8 ++++++++ exercises/23-Delete_element/app.py | 0 exercises/23-Delete_element/test.py | 0 exercises/24-Merge_list/README.md | 10 ++++++++++ exercises/24-Merge_list/app.py | 0 exercises/24-Merge_list/test.py | 0 6 files changed, 18 insertions(+) create mode 100644 exercises/23-Delete_element/README.md create mode 100644 exercises/23-Delete_element/app.py create mode 100644 exercises/23-Delete_element/test.py create mode 100644 exercises/24-Merge_list/README.md create mode 100644 exercises/24-Merge_list/app.py create mode 100644 exercises/24-Merge_list/test.py diff --git a/exercises/23-Delete_element/README.md b/exercises/23-Delete_element/README.md new file mode 100644 index 00000000..848621e2 --- /dev/null +++ b/exercises/23-Delete_element/README.md @@ -0,0 +1,8 @@ +# `23` +# Instructions from your teacher: +The only way to delete `Daniella` from the list (without cheating) +will be to create a new list with all the other people but Daniella. + +📝Instructions +1. Please create a deletePerson function that deletes any given person from the list + and returns a new list without that person. \ No newline at end of file diff --git a/exercises/23-Delete_element/app.py b/exercises/23-Delete_element/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/23-Delete_element/test.py b/exercises/23-Delete_element/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/24-Merge_list/README.md b/exercises/24-Merge_list/README.md new file mode 100644 index 00000000..64f09210 --- /dev/null +++ b/exercises/24-Merge_list/README.md @@ -0,0 +1,10 @@ +# `24` Instructions from your teacher: + +Since we live in a new world, there should be no colors or labels, right? + +# 📝Instructions +1.Write a function that merges two arrays and returns a single new list + merging all the values of both lists. + +💡HINT: +- You will have to loop though each list and insert their items into a new list. \ No newline at end of file diff --git a/exercises/24-Merge_list/app.py b/exercises/24-Merge_list/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/24-Merge_list/test.py b/exercises/24-Merge_list/test.py new file mode 100644 index 00000000..e69de29b From 9629d497970537f286d012457c79ab4d36faea01 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:14:45 +0000 Subject: [PATCH 40/92] readme divide and conquer --- exercises/24-Merge_list/app.py | 22 ++++++++++++++++++++++ exercises/25-Divide_and_conquer/README.md | 18 ++++++++++++++++++ exercises/25-Divide_and_conquer/app.py | 0 exercises/25-Divide_and_conquer/test.py | 0 4 files changed, 40 insertions(+) create mode 100644 exercises/25-Divide_and_conquer/README.md create mode 100644 exercises/25-Divide_and_conquer/app.py create mode 100644 exercises/25-Divide_and_conquer/test.py diff --git a/exercises/24-Merge_list/app.py b/exercises/24-Merge_list/app.py index e69de29b..0b03be60 100644 --- a/exercises/24-Merge_list/app.py +++ b/exercises/24-Merge_list/app.py @@ -0,0 +1,22 @@ +chunk_one = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ] +chunk_two = [ 'Lucas' , 'Jake','Scott','Amy', 'Molly','Hannah','Lucas'] + + +def merge_list(list1, list2): + merge = [] + for i in list1: + i += i + for j in list2: + j += j + merge = list1 + list2 + + return merge +print(merge_list(chunk_one, chunk_two)) + + + +def other(x1, x2): + for i in x2: + x1.append(i) + return x1 +print(other(chunk_one, chunk_two)) \ No newline at end of file diff --git a/exercises/25-Divide_and_conquer/README.md b/exercises/25-Divide_and_conquer/README.md new file mode 100644 index 00000000..4daec313 --- /dev/null +++ b/exercises/25-Divide_and_conquer/README.md @@ -0,0 +1,18 @@ +# `25` Instructions from your teacher: + +#📝Instructions +1. Create a function called mergeTwoList that expects an list of numbers (integers). +2. Loop through the list and separate the odd and the even numbers in different lists. +3. If the number is odd number push it to a placeholder list named odd. +4. If the number is even number push it to a placeholder list named even. +5. Then concatenate the odd list to the even list to combine them. Remember, the odd list comes first and you have to append the even mergeTwoList. + +```js +Example: +mergeTwoList([1,2,33,10,20,4]); + +[1,33,2,10,20,4] +``` + +💡Hints: +Create empty(placeholder) variables when you need to store data. \ No newline at end of file diff --git a/exercises/25-Divide_and_conquer/app.py b/exercises/25-Divide_and_conquer/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/25-Divide_and_conquer/test.py b/exercises/25-Divide_and_conquer/test.py new file mode 100644 index 00000000..e69de29b From f2b05345dc7dc8e3da0a30720a294233e2b9927b Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:24:14 +0000 Subject: [PATCH 41/92] 25 divide and conquer --- exercises/25-Divide_and_conquer/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/exercises/25-Divide_and_conquer/app.py b/exercises/25-Divide_and_conquer/app.py index e69de29b..3eab6cf4 100644 --- a/exercises/25-Divide_and_conquer/app.py +++ b/exercises/25-Divide_and_conquer/app.py @@ -0,0 +1,17 @@ +list_of_numbers = [4, 80, 85, 59, 37,25, 5, 64, 66, 81,20, 64, 41, 22, 76,76, 55, 96, 2, 68] + + +#Your code here: + + +# odd_number = [] +# even_number = [] +# def merge_two_list(items): +# for i in items: +# if i % 2 != 0: +# odd_number.append(i) +# i += i +# else: +# even_number.append(i) +# return odd_number + even_number +print(merge_two_list(list_of_numbers)) \ No newline at end of file From bbd4269d9ca96d48ea64b5de43ae62c18e1e500c Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:27:38 +0000 Subject: [PATCH 42/92] readme max integer from list --- exercises/26-Max_integer_from_list/README.md | 14 ++++++++++++++ exercises/26-Max_integer_from_list/app.py | 0 exercises/26-Max_integer_from_list/test.py | 0 3 files changed, 14 insertions(+) create mode 100644 exercises/26-Max_integer_from_list/README.md create mode 100644 exercises/26-Max_integer_from_list/app.py create mode 100644 exercises/26-Max_integer_from_list/test.py diff --git a/exercises/26-Max_integer_from_list/README.md b/exercises/26-Max_integer_from_list/README.md new file mode 100644 index 00000000..415b220a --- /dev/null +++ b/exercises/26-Max_integer_from_list/README.md @@ -0,0 +1,14 @@ +# `26` Instructions from your teacher: +Max integer from list +# 📝Instruccions +1. Write a script that finds the biggest integer in my_list + and print that number in the console with the print() function. + +💡Hint: +- Define an auxiliar variable and set the first value to 0. +- then compare the variables with all the items in the list. +- Replace the value every time the new element is bigger than the one stored in the auxiliar variable. +- At the end you will have the biggest number stored in the variable. + ```js +Your result should be 5435. +``` \ No newline at end of file diff --git a/exercises/26-Max_integer_from_list/app.py b/exercises/26-Max_integer_from_list/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/26-Max_integer_from_list/test.py b/exercises/26-Max_integer_from_list/test.py new file mode 100644 index 00000000..e69de29b From 8bfa65464ab3a6312f69cacbacb737952e9c7ed8 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:35:58 +0000 Subject: [PATCH 43/92] max integer from 26 --- exercises/26-Max_integer_from_list/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/exercises/26-Max_integer_from_list/app.py b/exercises/26-Max_integer_from_list/app.py index e69de29b..bc287682 100644 --- a/exercises/26-Max_integer_from_list/app.py +++ b/exercises/26-Max_integer_from_list/app.py @@ -0,0 +1,17 @@ +my_list = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34] + + +#Your code here: +"""the function it's not here, the student has to create the function from 0""" + +max_integer = my_list[0] +for i in my_list: + if i > max_integer: + max_integer = i +print(max_integer) + + +for i in range(len(my_list)): + if my_list[i] > max_integer: + max_integer.append(my_list[i]) +print(max_integer) \ No newline at end of file From 1fd23ec0231adebc8632aee692f514576c182017 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:43:30 +0000 Subject: [PATCH 44/92] readme min value --- exercises/27-For_loop_min_value/README.md | 14 ++++++++++++++ exercises/27-For_loop_min_value/app.py | 0 exercises/27-For_loop_min_value/test.py | 0 3 files changed, 14 insertions(+) create mode 100644 exercises/27-For_loop_min_value/README.md create mode 100644 exercises/27-For_loop_min_value/app.py create mode 100644 exercises/27-For_loop_min_value/test.py diff --git a/exercises/27-For_loop_min_value/README.md b/exercises/27-For_loop_min_value/README.md new file mode 100644 index 00000000..002214c9 --- /dev/null +++ b/exercises/27-For_loop_min_value/README.md @@ -0,0 +1,14 @@ +# `27` Instructions from your teacher: + +It is possible to traverse an list using the list for loop, you have to specify what to do on each iteration of the loop. + + +# 📝Instructions +1. Please use the for loop function to get the minimum value of the list and print it in the console. + +HINT +1. Declare an auxiliar global variable +2. Set its value to a very big integer +3. Every time you loop compare its value to the item value, if the item value is smaller + update the auxiliar variable value to the item value. +4. Outside of the loop, after the loop is finished, print the auxiliar value. diff --git a/exercises/27-For_loop_min_value/app.py b/exercises/27-For_loop_min_value/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/27-For_loop_min_value/test.py b/exercises/27-For_loop_min_value/test.py new file mode 100644 index 00000000..e69de29b From 6f026b2a859d254d36a970fa15ff1513f35695d3 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 4 Sep 2019 22:48:25 +0000 Subject: [PATCH 45/92] minimum number --- exercises/27-For_loop_min_value/app.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/exercises/27-For_loop_min_value/app.py b/exercises/27-For_loop_min_value/app.py index e69de29b..e860c5d8 100644 --- a/exercises/27-For_loop_min_value/app.py +++ b/exercises/27-For_loop_min_value/app.py @@ -0,0 +1,12 @@ +my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] + +#Your code here: + +"""the student have to create the algorism from 0 to complete""" + +number = 999999999 + +for i in my_list: + if i < number: + number = i +print(number) From 87d0a247c142340f38dc63ae59fb6473ea34f043 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 5 Sep 2019 00:30:43 +0000 Subject: [PATCH 46/92] test 03, 04 and 05 --- exercises/03-Access-and-Retrieve/test.py | 19 ++++++++++--------- exercises/04-Retrieve-items/app.py | 1 + exercises/04-Retrieve-items/test.py | 11 +++++++---- exercises/05-Print-the-last-one/app.py | 15 +++------------ exercises/05-Print-the-last-one/test.py | 15 ++++++++++----- exercises/06-Add-item-to-list/README.md | 12 +++++++----- exercises/06-Add-item-to-list/app.py | 10 +++++++--- exercises/07-loop-seventeen/test.py | 4 +++- exercises/28-Find_avg/README.md | 15 +++++++++++++++ exercises/28-Find_avg/app.py | 11 +++++++++++ exercises/28-Find_avg/test.py | 0 11 files changed, 74 insertions(+), 39 deletions(-) create mode 100644 exercises/28-Find_avg/README.md create mode 100644 exercises/28-Find_avg/app.py create mode 100644 exercises/28-Find_avg/test.py diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/03-Access-and-Retrieve/test.py index e312f622..18430bbb 100644 --- a/exercises/03-Access-and-Retrieve/test.py +++ b/exercises/03-Access-and-Retrieve/test.py @@ -5,17 +5,18 @@ from app import my_list import pytest - @pytest.mark.it('Your console have to print the 3rd item from the `list`') -def test_output_good(): +def test_output_one(): print(my_list[2]) captured = buffer.getvalue() - assert captured == "tuesday\n""None\n" - -@pytest.mark.it('This value should change to None') -def test_for_change_output(): - assert my_list[4] == "None" + assert "tuesday\n" in captured @pytest.mark.it('Your code have to print the position of step 2') -def test_position_output(): - assert my_list[4] == "None" \ No newline at end of file +def test_output_two(): + print(my_list[2]) + captured = buffer.getvalue() + assert "None\n" in captured + +@pytest.mark.it('Set index[4] to None') +def test_position_two(): + assert my_list[4] is None \ No newline at end of file diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 27ec6512..7d46a1b3 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -3,3 +3,4 @@ #output the 1st and 4th element from the list: print(my_list[0]) print(my_list[3]) + diff --git a/exercises/04-Retrieve-items/test.py b/exercises/04-Retrieve-items/test.py index 1f9a5a5e..56a1c265 100644 --- a/exercises/04-Retrieve-items/test.py +++ b/exercises/04-Retrieve-items/test.py @@ -7,11 +7,14 @@ @pytest.mark.it('You have to print the 1st element of the list') -def test_output(): +def test_output_one(): print(my_list[0]) - assert my_list[0] == 4 + captured = buffer.getvalue() + assert "4\n" in captured @pytest.mark.it('You have to print the 4th element of the list') -def test_output_item(): +def test_output_fourd(): print(my_list[3]) - assert my_list[3] == 43 + captured = buffer.getvalue() + assert "43\n" in captured + diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index ebe8f2ac..8c834b10 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -1,6 +1,4 @@ -#You have to import random function: import random -#Feel happy to write the code below, good luck: def generate_random_list(): aux_list = [] @@ -10,15 +8,8 @@ def generate_random_list(): aux_list.append(randonlength) i += i return aux_list - my_stupid_list = generate_random_list() -the_last_one = my_stupid_list[-1] - -print(the_last_one) - -# my_stupid_list = [] -# for i in range(1, 100): -# my_stupid_list.append(random.randint(1,100)) -# the_last_one = my_stupid_list[-1] -# print(the_last_one) \ No newline at end of file +#Feel happy to write the code below, good luck: +the_last_one = my_stupid_list[-1] +print("hju") diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index 5813e515..ee8a2e4c 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -1,11 +1,16 @@ import io import sys +import app +import pytest + sys.stdout = buffer = io.StringIO() +@pytest.mark.it("create and assign the value to the variable the_last_one") +def test_create_assign(): + assert app.the_last_one is not None -from app import my_stupid_list -import pytest -import random -@pytest.mark.it("assignt the value and print the last one") -def test_last_one(): +@pytest.mark.it("print in the console the_last_one") +def test_output(): + captured = buffer.getvalue() + assert str(app.the_last_one) in captured diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/06-Add-item-to-list/README.md index b2dc2e98..8f893eac 100644 --- a/exercises/06-Add-item-to-list/README.md +++ b/exercises/06-Add-item-to-list/README.md @@ -1,7 +1,8 @@ -# `06` Instructions from your teacher: -```js -Add 10 random integers to the "arr" list. -``` +# `06` Add items to the list + +# 📝Instructions +1. Add 10 random integers to the "arr" list. + 💡Tips: 1. You have to `import random` function @@ -9,6 +10,7 @@ Add 10 random integers to the "arr" list. 3. Search on Google how to use random function. Expected in the console something similar like this: -```js + +```py [4, 5, 734, 43, 45, 36, 2, 88, 12, 87, 79, 96, 58, 46, 7] ``` \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 75c778a8..1325715f 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,9 +1,13 @@ #Remember import random function here: -import random + list = [4,5,734,43,45] + #Your code here: -for i in range(1, 11): - list.append(random.randint(1, 10)) + print(list) + + +# for i in range(1, 11): +# list.append(random.randint(1, 10)) \ No newline at end of file diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index decfea20..7fd6c3b0 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -2,4 +2,6 @@ import sys sys.stdout = buffer = io.StringIO() - +@pytest.mark.it('Count 1 to 17') +def test_output_one(): + diff --git a/exercises/28-Find_avg/README.md b/exercises/28-Find_avg/README.md new file mode 100644 index 00000000..139b2195 --- /dev/null +++ b/exercises/28-Find_avg/README.md @@ -0,0 +1,15 @@ +# `28` Find average + +Another way to loop a list with the for loop will be using the IN statement like this: + +```py +for index in my_list: + print(myArray[index]) +``` + + +# 📝Instructions +Calculate the average value of all the items in the array and print it on the console. + +# 💡HINT: +To print the average, you have to add all the values and divide the result by the total length of the array. \ No newline at end of file diff --git a/exercises/28-Find_avg/app.py b/exercises/28-Find_avg/app.py new file mode 100644 index 00000000..9f3b75d8 --- /dev/null +++ b/exercises/28-Find_avg/app.py @@ -0,0 +1,11 @@ +my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] + +#Your code here: + + +total = 0 + +for val in my_list: + total += val +avg = total / len(my_list) +print(avg) diff --git a/exercises/28-Find_avg/test.py b/exercises/28-Find_avg/test.py new file mode 100644 index 00000000..e69de29b From 6091bd1231b7643ffd78789368665dec625782e9 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 5 Sep 2019 00:55:31 +0000 Subject: [PATCH 47/92] test py --- exercises/05-Print-the-last-one/app.py | 2 +- exercises/06-Add-item-to-list/app.py | 4 ++-- exercises/06-Add-item-to-list/test.py | 3 +-- exercises/07-loop-seventeen/README.md | 10 +++++----- exercises/07-loop-seventeen/app.py | 4 ++-- exercises/07-loop-seventeen/test.py | 7 ++++--- exercises/08-Loop-list/README.md | 7 ++++--- exercises/08-Loop-list/app.py | 5 +++-- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index 8c834b10..2252ffd2 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -12,4 +12,4 @@ def generate_random_list(): #Feel happy to write the code below, good luck: the_last_one = my_stupid_list[-1] -print("hju") +print(the_last_one) diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 1325715f..1a6722d8 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,9 +1,9 @@ #Remember import random function here: - +import random list = [4,5,734,43,45] -#Your code here: +#The magic is here: print(list) diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index 8f041a13..e77f4090 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -7,6 +7,5 @@ import random -@pytest.mark.it("add ten random number to the list") -def test_random(): + diff --git a/exercises/07-loop-seventeen/README.md b/exercises/07-loop-seventeen/README.md index 20b9ee24..7c5e42f9 100644 --- a/exercises/07-loop-seventeen/README.md +++ b/exercises/07-loop-seventeen/README.md @@ -1,8 +1,8 @@ -# `07` Instructions from your teacher: +# `07` Loop from 1 to 17 + +# 📝Instructions from your teacher: +1. Count from 1 to 17 with a loop and print each number on the console. -```js -Count from 1 to 17 with a loop and print each number on the console. -``` 💡HINT: @@ -10,7 +10,7 @@ Count from 1 to 17 with a loop and print each number on the console. `https://www.w3schools.com/python/python_for_loops.asp` Expected console result: -```js +```py 1 2 3 diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index f65f0162..e22f6197 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1,4 +1,4 @@ #Your code here, have fun: +for numb in range(1, 17): + print(numb) -for i in range(1, 18): - print(i) diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index 7fd6c3b0..d439d553 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -2,6 +2,7 @@ import sys sys.stdout = buffer = io.StringIO() -@pytest.mark.it('Count 1 to 17') -def test_output_one(): - + +from app import numb +import pytest + diff --git a/exercises/08-Loop-list/README.md b/exercises/08-Loop-list/README.md index 308e1a03..4588deb7 100644 --- a/exercises/08-Loop-list/README.md +++ b/exercises/08-Loop-list/README.md @@ -1,7 +1,8 @@ # `08` Instructions from your teacher: -The code right now is `printing the first item in the console.` Instead of doing that, print `all the elements` in the list. -```js +The code right now is `printing the first item in the console.` +Instead of doing that, print `all the elements` in the list. +```py You will have to loop through the whole array using a for loop. ``` @@ -10,7 +11,7 @@ You will have to loop through the whole array using a for loop. 2. print(my_list[index]); Expected console result: -```js +```py 232 32 1 diff --git a/exercises/08-Loop-list/app.py b/exercises/08-Loop-list/app.py index 692281ea..6c3dcbf1 100644 --- a/exercises/08-Loop-list/app.py +++ b/exercises/08-Loop-list/app.py @@ -2,11 +2,12 @@ #You don't to change nothing above, your code go below: + print(my_list[0]) -#for i in range(len(my_list)): -# print(my_list[i]) \ No newline at end of file +#for index in range(len(my_list)): +# print(my_list[index]) \ No newline at end of file From 63544c0bfa7371ef0e4945a7d85b9cc15efc94c6 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 5 Sep 2019 04:33:43 +0000 Subject: [PATCH 48/92] test exercises --- exercises/02-hello-world/app.py | 8 -------- exercises/03-Access-and-Retrieve/README.md | 4 +++- exercises/04-Retrieve-items/README.md | 3 ++- exercises/04-Retrieve-items/app.py | 3 +-- exercises/05-Print-the-last-one/README.md | 4 ++-- exercises/05-Print-the-last-one/app.py | 2 +- exercises/05-Print-the-last-one/test.py | 2 ++ exercises/06-Add-item-to-list/app.py | 10 ++++------ exercises/06-Add-item-to-list/test.py | 8 ++++---- exercises/07-loop-seventeen/app.py | 3 +-- exercises/07-loop-seventeen/test.py | 5 ++++- exercises/26-Max_integer_from_list/app.py | 2 +- exercises/26-Max_integer_from_list/test.py | 14 ++++++++++++++ 13 files changed, 39 insertions(+), 29 deletions(-) diff --git a/exercises/02-hello-world/app.py b/exercises/02-hello-world/app.py index 75117157..cc2c9bf4 100644 --- a/exercises/02-hello-world/app.py +++ b/exercises/02-hello-world/app.py @@ -1,10 +1,2 @@ #You have to print `hello` in the console, your code go here: - - - - - - - - diff --git a/exercises/03-Access-and-Retrieve/README.md b/exercises/03-Access-and-Retrieve/README.md index 478b4e86..8c40ba49 100644 --- a/exercises/03-Access-and-Retrieve/README.md +++ b/exercises/03-Access-and-Retrieve/README.md @@ -1,4 +1,6 @@ - # `03` Instructions from your teacher: +# `03` Access and retirve + +# 📝Instructions from your teacher: Lists are part of every programming language. They are the way to go when you want to have a "list of elements." diff --git a/exercises/04-Retrieve-items/README.md b/exercises/04-Retrieve-items/README.md index 7d2fa738..f5c6220d 100644 --- a/exercises/04-Retrieve-items/README.md +++ b/exercises/04-Retrieve-items/README.md @@ -1,4 +1,5 @@ -# `04` Instructions from your teacher: +# `04` Retrieve items + The only way of accessing a particular element in an `list`(in python), is using an index. An `index` is an integer number that represents the `position` you want to access in the list. diff --git a/exercises/04-Retrieve-items/app.py b/exercises/04-Retrieve-items/app.py index 7d46a1b3..d4305d84 100644 --- a/exercises/04-Retrieve-items/app.py +++ b/exercises/04-Retrieve-items/app.py @@ -1,6 +1,5 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] #output the 1st and 4th element from the list: -print(my_list[0]) -print(my_list[3]) + diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/05-Print-the-last-one/README.md index 37579d16..30240a68 100644 --- a/exercises/05-Print-the-last-one/README.md +++ b/exercises/05-Print-the-last-one/README.md @@ -1,9 +1,9 @@ -# `05` Instructions from your teacher: +# `05` Print the last one You will never know how many `items` my_stupid_list has because it is being `randomly` generated during runtime. You know that the property: -```js +```py len(name_list) function ``` diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/05-Print-the-last-one/app.py index 2252ffd2..ec34c20d 100644 --- a/exercises/05-Print-the-last-one/app.py +++ b/exercises/05-Print-the-last-one/app.py @@ -12,4 +12,4 @@ def generate_random_list(): #Feel happy to write the code below, good luck: the_last_one = my_stupid_list[-1] -print(the_last_one) +print(the_last_one) \ No newline at end of file diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/05-Print-the-last-one/test.py index ee8a2e4c..89f8ab19 100644 --- a/exercises/05-Print-the-last-one/test.py +++ b/exercises/05-Print-the-last-one/test.py @@ -3,6 +3,8 @@ import app import pytest +from app import the_last_one + sys.stdout = buffer = io.StringIO() @pytest.mark.it("create and assign the value to the variable the_last_one") diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/06-Add-item-to-list/app.py index 1a6722d8..499b8830 100644 --- a/exercises/06-Add-item-to-list/app.py +++ b/exercises/06-Add-item-to-list/app.py @@ -1,13 +1,11 @@ #Remember import random function here: import random -list = [4,5,734,43,45] +my_list = [4,5,734,43,45] #The magic is here: +for num in range(1, 11): + my_list.append(random.randint(1, 10)) -print(list) - - -# for i in range(1, 11): -# list.append(random.randint(1, 10)) \ No newline at end of file +print(my_list) \ No newline at end of file diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/06-Add-item-to-list/test.py index e77f4090..c171d6b1 100644 --- a/exercises/06-Add-item-to-list/test.py +++ b/exercises/06-Add-item-to-list/test.py @@ -2,10 +2,10 @@ import sys sys.stdout = buffer = io.StringIO() -from app import list import pytest +import app import random - - - +@pytest.mark.it("Add ten random numbers to the list") +def test_add_numb(): + assert app.my_list.append(random.randint(1, 10)) \ No newline at end of file diff --git a/exercises/07-loop-seventeen/app.py b/exercises/07-loop-seventeen/app.py index e22f6197..ec89829b 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/07-loop-seventeen/app.py @@ -1,4 +1,3 @@ #Your code here, have fun: -for numb in range(1, 17): - print(numb) + diff --git a/exercises/07-loop-seventeen/test.py b/exercises/07-loop-seventeen/test.py index d439d553..5f992456 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/07-loop-seventeen/test.py @@ -3,6 +3,9 @@ sys.stdout = buffer = io.StringIO() -from app import numb + import pytest +from app import my_list +@pytest.mark.it("Add ten random numbers") +def test_add_number(): diff --git a/exercises/26-Max_integer_from_list/app.py b/exercises/26-Max_integer_from_list/app.py index bc287682..a2b23460 100644 --- a/exercises/26-Max_integer_from_list/app.py +++ b/exercises/26-Max_integer_from_list/app.py @@ -2,7 +2,7 @@ #Your code here: -"""the function it's not here, the student has to create the function from 0""" +"""the function it's not here, the student has to create the function from 0 to the end""" max_integer = my_list[0] for i in my_list: diff --git a/exercises/26-Max_integer_from_list/test.py b/exercises/26-Max_integer_from_list/test.py index e69de29b..453423f6 100644 --- a/exercises/26-Max_integer_from_list/test.py +++ b/exercises/26-Max_integer_from_list/test.py @@ -0,0 +1,14 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + + + +import pytest +import app + + +@pytest.mark.it("Max integer from the list") +def test_output(): + captured == buffer.getvalue() + assert "5435\n" in captured \ No newline at end of file From 18c65811d6f07be276ed288dfd335f466c9b9c9f Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 6 Sep 2019 02:11:46 +0000 Subject: [PATCH 49/92] readme 29 --- exercises/29-Nested_listy/README.md | 19 +++++++++++++++++++ exercises/29-Nested_listy/app.py | 12 ++++++++++++ exercises/29-Nested_listy/test.py | 0 3 files changed, 31 insertions(+) create mode 100644 exercises/29-Nested_listy/README.md create mode 100644 exercises/29-Nested_listy/app.py create mode 100644 exercises/29-Nested_listy/test.py diff --git a/exercises/29-Nested_listy/README.md b/exercises/29-Nested_listy/README.md new file mode 100644 index 00000000..818e3208 --- /dev/null +++ b/exercises/29-Nested_listy/README.md @@ -0,0 +1,19 @@ +Instructions from your teacher: +# `29` Nested list +It is possible to find an list comprised of other lists (it is called a two-dimension list or matrix). + +In this example, we have a list of coordinates that you can access by doing the following: + +//longitude = [] +// for loop in coordinate longitude +longitude = coordinatesArray[0][1]; + + +Instructions: +Loop through the array printing only the longitudes. + +The result should be something like this: +-112.633853 +-63.987 +-81.901693 +-71.653268 diff --git a/exercises/29-Nested_listy/app.py b/exercises/29-Nested_listy/app.py new file mode 100644 index 00000000..0e6380fa --- /dev/null +++ b/exercises/29-Nested_listy/app.py @@ -0,0 +1,12 @@ + +coordinatesArray = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]] + +# Your code go here: +"""from here the student hax to decleare the function""" +"""declare the empty variable""" +# longitude = [] + +# for grades in coordinatesArray: +# longitude.append(grades[1]) +# grades += grades +# print(longitude) diff --git a/exercises/29-Nested_listy/test.py b/exercises/29-Nested_listy/test.py new file mode 100644 index 00000000..e69de29b From 9ba7c0fbccf9754378f72303564596405391446b Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 6 Sep 2019 02:26:10 +0000 Subject: [PATCH 50/92] readme 30 --- exercises/29-Nested_listy/test.py | 4 ++++ exercises/30-Map_an_list/README.md | 0 exercises/30-Map_an_list/app.py | 0 exercises/30-Map_an_list/test.py | 0 4 files changed, 4 insertions(+) create mode 100644 exercises/30-Map_an_list/README.md create mode 100644 exercises/30-Map_an_list/app.py create mode 100644 exercises/30-Map_an_list/test.py diff --git a/exercises/29-Nested_listy/test.py b/exercises/29-Nested_listy/test.py index e69de29b..23aa2c4e 100644 --- a/exercises/29-Nested_listy/test.py +++ b/exercises/29-Nested_listy/test.py @@ -0,0 +1,4 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + diff --git a/exercises/30-Map_an_list/README.md b/exercises/30-Map_an_list/README.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/30-Map_an_list/app.py b/exercises/30-Map_an_list/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/30-Map_an_list/test.py b/exercises/30-Map_an_list/test.py new file mode 100644 index 00000000..e69de29b From 3752098b602667ea57db31b7114c449b8123f0ad Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 6 Sep 2019 22:59:37 +0000 Subject: [PATCH 51/92] exercises --- .../{01-welcome => 00-welcome}/README.md | 0 .../README.md | 0 .../{02-hello-world => 01-hello-world}/app.py | 2 ++ .../test.py | 1 + .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 1 - .../test.py | 1 + .../{08-Loop-list => 02-Loop-list}/README.md | 0 .../{08-Loop-list => 02-Loop-list}/app.py | 0 .../{08-Loop-list => 02-Loop-list}/test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../RAEDME.md | 0 .../app.py | 0 .../test.py | 0 .../{15-flip_list => 03-flip_list}/README.md | 0 .../{15-flip_list => 03-flip_list}/app.py | 0 .../{15-flip_list => 03-flip_list}/test.py | 0 .../README.md | 0 .../{16-mixed_list => 04-mixed_list}/app.py | 0 .../{16-mixed_list => 04-mixed_list}/test.py | 0 .../{17-count_on => 04.1-count_on}/README.md | 0 .../{17-count_on => 04.1-count_on}/app.py | 0 .../{17-count_on => 04.1-count_on}/test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 4 +++ .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../{24-Merge_list => 08.1-Merge_list}/app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../README.md | 0 .../app.py | 0 .../test.py | 0 .../{28-Find_avg => 10-Find_avg}/README.md | 0 exercises/{28-Find_avg => 10-Find_avg}/app.py | 0 .../{28-Find_avg => 10-Find_avg}/test.py | 0 .../README.md | 0 .../app.py | 2 +- .../test.py | 0 exercises/12-Map_an_list/README.md | 28 +++++++++++++++++++ .../{30-Map_an_list => 12-Map_an_list}/app.py | 0 .../test.py | 0 exercises/30-Map_an_list/README.md | 0 89 files changed, 37 insertions(+), 2 deletions(-) rename exercises/{01-welcome => 00-welcome}/README.md (100%) rename exercises/{02-hello-world => 01-hello-world}/README.md (100%) rename exercises/{02-hello-world => 01-hello-world}/app.py (79%) rename exercises/{02-hello-world => 01-hello-world}/test.py (99%) rename exercises/{03-Access-and-Retrieve => 01.1-Access-and-Retrieve}/README.md (100%) rename exercises/{03-Access-and-Retrieve => 01.1-Access-and-Retrieve}/app.py (100%) rename exercises/{03-Access-and-Retrieve => 01.1-Access-and-Retrieve}/test.py (100%) rename exercises/{04-Retrieve-items => 01.2-Retrieve-items}/README.md (100%) rename exercises/{04-Retrieve-items => 01.2-Retrieve-items}/app.py (100%) rename exercises/{04-Retrieve-items => 01.2-Retrieve-items}/test.py (100%) rename exercises/{05-Print-the-last-one => 01.3-Print-the-last-one}/README.md (100%) rename exercises/{05-Print-the-last-one => 01.3-Print-the-last-one}/app.py (100%) rename exercises/{05-Print-the-last-one => 01.3-Print-the-last-one}/test.py (100%) rename exercises/{06-Add-item-to-list => 01.4-Add-item-to-list}/README.md (100%) rename exercises/{06-Add-item-to-list => 01.4-Add-item-to-list}/app.py (100%) rename exercises/{06-Add-item-to-list => 01.4-Add-item-to-list}/test.py (100%) rename exercises/{07-loop-seventeen => 01.5-loop-seventeen}/README.md (100%) rename exercises/{07-loop-seventeen => 01.5-loop-seventeen}/app.py (96%) rename exercises/{07-loop-seventeen => 01.5-loop-seventeen}/test.py (97%) rename exercises/{08-Loop-list => 02-Loop-list}/README.md (100%) rename exercises/{08-Loop-list => 02-Loop-list}/app.py (100%) rename exercises/{08-Loop-list => 02-Loop-list}/test.py (100%) rename exercises/{09-Loop-from-the-top => 02.1-Loop-from-the-top}/README.md (100%) rename exercises/{09-Loop-from-the-top => 02.1-Loop-from-the-top}/app.py (100%) rename exercises/{09-Loop-from-the-top => 02.1-Loop-from-the-top}/test.py (100%) rename exercises/{10-Loop-adding-two => 02.2-Loop-adding-two}/README.md (100%) rename exercises/{10-Loop-adding-two => 02.2-Loop-adding-two}/app.py (100%) rename exercises/{10-Loop-adding-two => 02.2-Loop-adding-two}/test.py (100%) rename exercises/{11-loop-from-the-half-to-the-end => 02.3-loop-from-the-half-to-the-end}/README.md (100%) rename exercises/{11-loop-from-the-half-to-the-end => 02.3-loop-from-the-half-to-the-end}/app.py (100%) rename exercises/{11-loop-from-the-half-to-the-end => 02.3-loop-from-the-half-to-the-end}/test.py (100%) rename exercises/{12-One_last_looping => 02.4-One_last_looping}/README.md (100%) rename exercises/{12-One_last_looping => 02.4-One_last_looping}/app.py (100%) rename exercises/{12-One_last_looping => 02.4-One_last_looping}/test.py (100%) rename exercises/{13-Finding_wally => 02.5-Finding_wally}/README.md (100%) rename exercises/{13-Finding_wally => 02.5-Finding_wally}/app.py (100%) rename exercises/{13-Finding_wally => 02.5-Finding_wally}/test.py (100%) rename exercises/{14-letter_counter => 02.6-letter_counter}/RAEDME.md (100%) rename exercises/{14-letter_counter => 02.6-letter_counter}/app.py (100%) rename exercises/{14-letter_counter => 02.6-letter_counter}/test.py (100%) rename exercises/{15-flip_list => 03-flip_list}/README.md (100%) rename exercises/{15-flip_list => 03-flip_list}/app.py (100%) rename exercises/{15-flip_list => 03-flip_list}/test.py (100%) rename exercises/{16-mixed_list => 04-mixed_list}/README.md (100%) rename exercises/{16-mixed_list => 04-mixed_list}/app.py (100%) rename exercises/{16-mixed_list => 04-mixed_list}/test.py (100%) rename exercises/{17-count_on => 04.1-count_on}/README.md (100%) rename exercises/{17-count_on => 04.1-count_on}/app.py (100%) rename exercises/{17-count_on => 04.1-count_on}/test.py (100%) rename exercises/{18-Sum_all_items => 05-Sum_all_items}/README.md (100%) rename exercises/{18-Sum_all_items => 05-Sum_all_items}/app.py (100%) rename exercises/{18-Sum_all_items => 05-Sum_all_items}/test.py (100%) rename exercises/{19-sum_odd_items => 05.1-sum_odd_items}/README.md (100%) rename exercises/{19-sum_odd_items => 05.1-sum_odd_items}/app.py (100%) rename exercises/{19-sum_odd_items => 05.1-sum_odd_items}/test.py (100%) rename exercises/{20-forEach_loop => 06-forEach_loop}/README.md (100%) rename exercises/{20-forEach_loop => 06-forEach_loop}/app.py (86%) rename exercises/{20-forEach_loop => 06-forEach_loop}/test.py (100%) rename exercises/{21-Everything_is_awesome => 06.1-Everything_is_awesome}/README.md (100%) rename exercises/{21-Everything_is_awesome => 06.1-Everything_is_awesome}/app.py (100%) rename exercises/{21-Everything_is_awesome => 06.1-Everything_is_awesome}/test.py (100%) rename exercises/{22-Dowhile_DO_DO => 07-Dowhile_DO_DO}/README.md (100%) rename exercises/{22-Dowhile_DO_DO => 07-Dowhile_DO_DO}/app.py (100%) rename exercises/{22-Dowhile_DO_DO => 07-Dowhile_DO_DO}/test.py (100%) rename exercises/{23-Delete_element => 08-Delete_element}/README.md (100%) rename exercises/{23-Delete_element => 08-Delete_element}/app.py (100%) rename exercises/{23-Delete_element => 08-Delete_element}/test.py (100%) rename exercises/{24-Merge_list => 08.1-Merge_list}/README.md (100%) rename exercises/{24-Merge_list => 08.1-Merge_list}/app.py (100%) rename exercises/{24-Merge_list => 08.1-Merge_list}/test.py (100%) rename exercises/{25-Divide_and_conquer => 08.2-Divide_and_conquer}/README.md (100%) rename exercises/{25-Divide_and_conquer => 08.2-Divide_and_conquer}/app.py (100%) rename exercises/{25-Divide_and_conquer => 08.2-Divide_and_conquer}/test.py (100%) rename exercises/{26-Max_integer_from_list => 09-Max_integer_from_list}/README.md (100%) rename exercises/{26-Max_integer_from_list => 09-Max_integer_from_list}/app.py (100%) rename exercises/{26-Max_integer_from_list => 09-Max_integer_from_list}/test.py (100%) rename exercises/{27-For_loop_min_value => 09.1-For_loop_min_value}/README.md (100%) rename exercises/{27-For_loop_min_value => 09.1-For_loop_min_value}/app.py (100%) rename exercises/{27-For_loop_min_value => 09.1-For_loop_min_value}/test.py (100%) rename exercises/{28-Find_avg => 10-Find_avg}/README.md (100%) rename exercises/{28-Find_avg => 10-Find_avg}/app.py (100%) rename exercises/{28-Find_avg => 10-Find_avg}/test.py (100%) rename exercises/{29-Nested_listy => 11-Nested_list}/README.md (100%) rename exercises/{29-Nested_listy => 11-Nested_list}/app.py (83%) rename exercises/{29-Nested_listy => 11-Nested_list}/test.py (100%) create mode 100644 exercises/12-Map_an_list/README.md rename exercises/{30-Map_an_list => 12-Map_an_list}/app.py (100%) rename exercises/{30-Map_an_list => 12-Map_an_list}/test.py (100%) delete mode 100644 exercises/30-Map_an_list/README.md diff --git a/exercises/01-welcome/README.md b/exercises/00-welcome/README.md similarity index 100% rename from exercises/01-welcome/README.md rename to exercises/00-welcome/README.md diff --git a/exercises/02-hello-world/README.md b/exercises/01-hello-world/README.md similarity index 100% rename from exercises/02-hello-world/README.md rename to exercises/01-hello-world/README.md diff --git a/exercises/02-hello-world/app.py b/exercises/01-hello-world/app.py similarity index 79% rename from exercises/02-hello-world/app.py rename to exercises/01-hello-world/app.py index cc2c9bf4..9b473b3c 100644 --- a/exercises/02-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,2 +1,4 @@ #You have to print `hello` in the console, your code go here: +print("hello") + diff --git a/exercises/02-hello-world/test.py b/exercises/01-hello-world/test.py similarity index 99% rename from exercises/02-hello-world/test.py rename to exercises/01-hello-world/test.py index 4f94ffb0..11be726b 100644 --- a/exercises/02-hello-world/test.py +++ b/exercises/01-hello-world/test.py @@ -19,3 +19,4 @@ def test_for_function_output(capsys): @pytest.mark.it('Your function needs to return True') def test_for_function_return(capsys): assert my_function() == True + diff --git a/exercises/03-Access-and-Retrieve/README.md b/exercises/01.1-Access-and-Retrieve/README.md similarity index 100% rename from exercises/03-Access-and-Retrieve/README.md rename to exercises/01.1-Access-and-Retrieve/README.md diff --git a/exercises/03-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py similarity index 100% rename from exercises/03-Access-and-Retrieve/app.py rename to exercises/01.1-Access-and-Retrieve/app.py diff --git a/exercises/03-Access-and-Retrieve/test.py b/exercises/01.1-Access-and-Retrieve/test.py similarity index 100% rename from exercises/03-Access-and-Retrieve/test.py rename to exercises/01.1-Access-and-Retrieve/test.py diff --git a/exercises/04-Retrieve-items/README.md b/exercises/01.2-Retrieve-items/README.md similarity index 100% rename from exercises/04-Retrieve-items/README.md rename to exercises/01.2-Retrieve-items/README.md diff --git a/exercises/04-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py similarity index 100% rename from exercises/04-Retrieve-items/app.py rename to exercises/01.2-Retrieve-items/app.py diff --git a/exercises/04-Retrieve-items/test.py b/exercises/01.2-Retrieve-items/test.py similarity index 100% rename from exercises/04-Retrieve-items/test.py rename to exercises/01.2-Retrieve-items/test.py diff --git a/exercises/05-Print-the-last-one/README.md b/exercises/01.3-Print-the-last-one/README.md similarity index 100% rename from exercises/05-Print-the-last-one/README.md rename to exercises/01.3-Print-the-last-one/README.md diff --git a/exercises/05-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py similarity index 100% rename from exercises/05-Print-the-last-one/app.py rename to exercises/01.3-Print-the-last-one/app.py diff --git a/exercises/05-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py similarity index 100% rename from exercises/05-Print-the-last-one/test.py rename to exercises/01.3-Print-the-last-one/test.py diff --git a/exercises/06-Add-item-to-list/README.md b/exercises/01.4-Add-item-to-list/README.md similarity index 100% rename from exercises/06-Add-item-to-list/README.md rename to exercises/01.4-Add-item-to-list/README.md diff --git a/exercises/06-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py similarity index 100% rename from exercises/06-Add-item-to-list/app.py rename to exercises/01.4-Add-item-to-list/app.py diff --git a/exercises/06-Add-item-to-list/test.py b/exercises/01.4-Add-item-to-list/test.py similarity index 100% rename from exercises/06-Add-item-to-list/test.py rename to exercises/01.4-Add-item-to-list/test.py diff --git a/exercises/07-loop-seventeen/README.md b/exercises/01.5-loop-seventeen/README.md similarity index 100% rename from exercises/07-loop-seventeen/README.md rename to exercises/01.5-loop-seventeen/README.md diff --git a/exercises/07-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py similarity index 96% rename from exercises/07-loop-seventeen/app.py rename to exercises/01.5-loop-seventeen/app.py index ec89829b..1f0aada8 100644 --- a/exercises/07-loop-seventeen/app.py +++ b/exercises/01.5-loop-seventeen/app.py @@ -1,3 +1,2 @@ #Your code here, have fun: - diff --git a/exercises/07-loop-seventeen/test.py b/exercises/01.5-loop-seventeen/test.py similarity index 97% rename from exercises/07-loop-seventeen/test.py rename to exercises/01.5-loop-seventeen/test.py index 5f992456..1a79d9c9 100644 --- a/exercises/07-loop-seventeen/test.py +++ b/exercises/01.5-loop-seventeen/test.py @@ -9,3 +9,4 @@ @pytest.mark.it("Add ten random numbers") def test_add_number(): + diff --git a/exercises/08-Loop-list/README.md b/exercises/02-Loop-list/README.md similarity index 100% rename from exercises/08-Loop-list/README.md rename to exercises/02-Loop-list/README.md diff --git a/exercises/08-Loop-list/app.py b/exercises/02-Loop-list/app.py similarity index 100% rename from exercises/08-Loop-list/app.py rename to exercises/02-Loop-list/app.py diff --git a/exercises/08-Loop-list/test.py b/exercises/02-Loop-list/test.py similarity index 100% rename from exercises/08-Loop-list/test.py rename to exercises/02-Loop-list/test.py diff --git a/exercises/09-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md similarity index 100% rename from exercises/09-Loop-from-the-top/README.md rename to exercises/02.1-Loop-from-the-top/README.md diff --git a/exercises/09-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py similarity index 100% rename from exercises/09-Loop-from-the-top/app.py rename to exercises/02.1-Loop-from-the-top/app.py diff --git a/exercises/09-Loop-from-the-top/test.py b/exercises/02.1-Loop-from-the-top/test.py similarity index 100% rename from exercises/09-Loop-from-the-top/test.py rename to exercises/02.1-Loop-from-the-top/test.py diff --git a/exercises/10-Loop-adding-two/README.md b/exercises/02.2-Loop-adding-two/README.md similarity index 100% rename from exercises/10-Loop-adding-two/README.md rename to exercises/02.2-Loop-adding-two/README.md diff --git a/exercises/10-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py similarity index 100% rename from exercises/10-Loop-adding-two/app.py rename to exercises/02.2-Loop-adding-two/app.py diff --git a/exercises/10-Loop-adding-two/test.py b/exercises/02.2-Loop-adding-two/test.py similarity index 100% rename from exercises/10-Loop-adding-two/test.py rename to exercises/02.2-Loop-adding-two/test.py diff --git a/exercises/11-loop-from-the-half-to-the-end/README.md b/exercises/02.3-loop-from-the-half-to-the-end/README.md similarity index 100% rename from exercises/11-loop-from-the-half-to-the-end/README.md rename to exercises/02.3-loop-from-the-half-to-the-end/README.md diff --git a/exercises/11-loop-from-the-half-to-the-end/app.py b/exercises/02.3-loop-from-the-half-to-the-end/app.py similarity index 100% rename from exercises/11-loop-from-the-half-to-the-end/app.py rename to exercises/02.3-loop-from-the-half-to-the-end/app.py diff --git a/exercises/11-loop-from-the-half-to-the-end/test.py b/exercises/02.3-loop-from-the-half-to-the-end/test.py similarity index 100% rename from exercises/11-loop-from-the-half-to-the-end/test.py rename to exercises/02.3-loop-from-the-half-to-the-end/test.py diff --git a/exercises/12-One_last_looping/README.md b/exercises/02.4-One_last_looping/README.md similarity index 100% rename from exercises/12-One_last_looping/README.md rename to exercises/02.4-One_last_looping/README.md diff --git a/exercises/12-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py similarity index 100% rename from exercises/12-One_last_looping/app.py rename to exercises/02.4-One_last_looping/app.py diff --git a/exercises/12-One_last_looping/test.py b/exercises/02.4-One_last_looping/test.py similarity index 100% rename from exercises/12-One_last_looping/test.py rename to exercises/02.4-One_last_looping/test.py diff --git a/exercises/13-Finding_wally/README.md b/exercises/02.5-Finding_wally/README.md similarity index 100% rename from exercises/13-Finding_wally/README.md rename to exercises/02.5-Finding_wally/README.md diff --git a/exercises/13-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py similarity index 100% rename from exercises/13-Finding_wally/app.py rename to exercises/02.5-Finding_wally/app.py diff --git a/exercises/13-Finding_wally/test.py b/exercises/02.5-Finding_wally/test.py similarity index 100% rename from exercises/13-Finding_wally/test.py rename to exercises/02.5-Finding_wally/test.py diff --git a/exercises/14-letter_counter/RAEDME.md b/exercises/02.6-letter_counter/RAEDME.md similarity index 100% rename from exercises/14-letter_counter/RAEDME.md rename to exercises/02.6-letter_counter/RAEDME.md diff --git a/exercises/14-letter_counter/app.py b/exercises/02.6-letter_counter/app.py similarity index 100% rename from exercises/14-letter_counter/app.py rename to exercises/02.6-letter_counter/app.py diff --git a/exercises/14-letter_counter/test.py b/exercises/02.6-letter_counter/test.py similarity index 100% rename from exercises/14-letter_counter/test.py rename to exercises/02.6-letter_counter/test.py diff --git a/exercises/15-flip_list/README.md b/exercises/03-flip_list/README.md similarity index 100% rename from exercises/15-flip_list/README.md rename to exercises/03-flip_list/README.md diff --git a/exercises/15-flip_list/app.py b/exercises/03-flip_list/app.py similarity index 100% rename from exercises/15-flip_list/app.py rename to exercises/03-flip_list/app.py diff --git a/exercises/15-flip_list/test.py b/exercises/03-flip_list/test.py similarity index 100% rename from exercises/15-flip_list/test.py rename to exercises/03-flip_list/test.py diff --git a/exercises/16-mixed_list/README.md b/exercises/04-mixed_list/README.md similarity index 100% rename from exercises/16-mixed_list/README.md rename to exercises/04-mixed_list/README.md diff --git a/exercises/16-mixed_list/app.py b/exercises/04-mixed_list/app.py similarity index 100% rename from exercises/16-mixed_list/app.py rename to exercises/04-mixed_list/app.py diff --git a/exercises/16-mixed_list/test.py b/exercises/04-mixed_list/test.py similarity index 100% rename from exercises/16-mixed_list/test.py rename to exercises/04-mixed_list/test.py diff --git a/exercises/17-count_on/README.md b/exercises/04.1-count_on/README.md similarity index 100% rename from exercises/17-count_on/README.md rename to exercises/04.1-count_on/README.md diff --git a/exercises/17-count_on/app.py b/exercises/04.1-count_on/app.py similarity index 100% rename from exercises/17-count_on/app.py rename to exercises/04.1-count_on/app.py diff --git a/exercises/17-count_on/test.py b/exercises/04.1-count_on/test.py similarity index 100% rename from exercises/17-count_on/test.py rename to exercises/04.1-count_on/test.py diff --git a/exercises/18-Sum_all_items/README.md b/exercises/05-Sum_all_items/README.md similarity index 100% rename from exercises/18-Sum_all_items/README.md rename to exercises/05-Sum_all_items/README.md diff --git a/exercises/18-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py similarity index 100% rename from exercises/18-Sum_all_items/app.py rename to exercises/05-Sum_all_items/app.py diff --git a/exercises/18-Sum_all_items/test.py b/exercises/05-Sum_all_items/test.py similarity index 100% rename from exercises/18-Sum_all_items/test.py rename to exercises/05-Sum_all_items/test.py diff --git a/exercises/19-sum_odd_items/README.md b/exercises/05.1-sum_odd_items/README.md similarity index 100% rename from exercises/19-sum_odd_items/README.md rename to exercises/05.1-sum_odd_items/README.md diff --git a/exercises/19-sum_odd_items/app.py b/exercises/05.1-sum_odd_items/app.py similarity index 100% rename from exercises/19-sum_odd_items/app.py rename to exercises/05.1-sum_odd_items/app.py diff --git a/exercises/19-sum_odd_items/test.py b/exercises/05.1-sum_odd_items/test.py similarity index 100% rename from exercises/19-sum_odd_items/test.py rename to exercises/05.1-sum_odd_items/test.py diff --git a/exercises/20-forEach_loop/README.md b/exercises/06-forEach_loop/README.md similarity index 100% rename from exercises/20-forEach_loop/README.md rename to exercises/06-forEach_loop/README.md diff --git a/exercises/20-forEach_loop/app.py b/exercises/06-forEach_loop/app.py similarity index 86% rename from exercises/20-forEach_loop/app.py rename to exercises/06-forEach_loop/app.py index 45ee11de..caa4a658 100644 --- a/exercises/20-forEach_loop/app.py +++ b/exercises/06-forEach_loop/app.py @@ -1,3 +1,7 @@ my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] +for numb in my_list: + #the magic go here: + + print(numb) \ No newline at end of file diff --git a/exercises/20-forEach_loop/test.py b/exercises/06-forEach_loop/test.py similarity index 100% rename from exercises/20-forEach_loop/test.py rename to exercises/06-forEach_loop/test.py diff --git a/exercises/21-Everything_is_awesome/README.md b/exercises/06.1-Everything_is_awesome/README.md similarity index 100% rename from exercises/21-Everything_is_awesome/README.md rename to exercises/06.1-Everything_is_awesome/README.md diff --git a/exercises/21-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py similarity index 100% rename from exercises/21-Everything_is_awesome/app.py rename to exercises/06.1-Everything_is_awesome/app.py diff --git a/exercises/21-Everything_is_awesome/test.py b/exercises/06.1-Everything_is_awesome/test.py similarity index 100% rename from exercises/21-Everything_is_awesome/test.py rename to exercises/06.1-Everything_is_awesome/test.py diff --git a/exercises/22-Dowhile_DO_DO/README.md b/exercises/07-Dowhile_DO_DO/README.md similarity index 100% rename from exercises/22-Dowhile_DO_DO/README.md rename to exercises/07-Dowhile_DO_DO/README.md diff --git a/exercises/22-Dowhile_DO_DO/app.py b/exercises/07-Dowhile_DO_DO/app.py similarity index 100% rename from exercises/22-Dowhile_DO_DO/app.py rename to exercises/07-Dowhile_DO_DO/app.py diff --git a/exercises/22-Dowhile_DO_DO/test.py b/exercises/07-Dowhile_DO_DO/test.py similarity index 100% rename from exercises/22-Dowhile_DO_DO/test.py rename to exercises/07-Dowhile_DO_DO/test.py diff --git a/exercises/23-Delete_element/README.md b/exercises/08-Delete_element/README.md similarity index 100% rename from exercises/23-Delete_element/README.md rename to exercises/08-Delete_element/README.md diff --git a/exercises/23-Delete_element/app.py b/exercises/08-Delete_element/app.py similarity index 100% rename from exercises/23-Delete_element/app.py rename to exercises/08-Delete_element/app.py diff --git a/exercises/23-Delete_element/test.py b/exercises/08-Delete_element/test.py similarity index 100% rename from exercises/23-Delete_element/test.py rename to exercises/08-Delete_element/test.py diff --git a/exercises/24-Merge_list/README.md b/exercises/08.1-Merge_list/README.md similarity index 100% rename from exercises/24-Merge_list/README.md rename to exercises/08.1-Merge_list/README.md diff --git a/exercises/24-Merge_list/app.py b/exercises/08.1-Merge_list/app.py similarity index 100% rename from exercises/24-Merge_list/app.py rename to exercises/08.1-Merge_list/app.py diff --git a/exercises/24-Merge_list/test.py b/exercises/08.1-Merge_list/test.py similarity index 100% rename from exercises/24-Merge_list/test.py rename to exercises/08.1-Merge_list/test.py diff --git a/exercises/25-Divide_and_conquer/README.md b/exercises/08.2-Divide_and_conquer/README.md similarity index 100% rename from exercises/25-Divide_and_conquer/README.md rename to exercises/08.2-Divide_and_conquer/README.md diff --git a/exercises/25-Divide_and_conquer/app.py b/exercises/08.2-Divide_and_conquer/app.py similarity index 100% rename from exercises/25-Divide_and_conquer/app.py rename to exercises/08.2-Divide_and_conquer/app.py diff --git a/exercises/25-Divide_and_conquer/test.py b/exercises/08.2-Divide_and_conquer/test.py similarity index 100% rename from exercises/25-Divide_and_conquer/test.py rename to exercises/08.2-Divide_and_conquer/test.py diff --git a/exercises/26-Max_integer_from_list/README.md b/exercises/09-Max_integer_from_list/README.md similarity index 100% rename from exercises/26-Max_integer_from_list/README.md rename to exercises/09-Max_integer_from_list/README.md diff --git a/exercises/26-Max_integer_from_list/app.py b/exercises/09-Max_integer_from_list/app.py similarity index 100% rename from exercises/26-Max_integer_from_list/app.py rename to exercises/09-Max_integer_from_list/app.py diff --git a/exercises/26-Max_integer_from_list/test.py b/exercises/09-Max_integer_from_list/test.py similarity index 100% rename from exercises/26-Max_integer_from_list/test.py rename to exercises/09-Max_integer_from_list/test.py diff --git a/exercises/27-For_loop_min_value/README.md b/exercises/09.1-For_loop_min_value/README.md similarity index 100% rename from exercises/27-For_loop_min_value/README.md rename to exercises/09.1-For_loop_min_value/README.md diff --git a/exercises/27-For_loop_min_value/app.py b/exercises/09.1-For_loop_min_value/app.py similarity index 100% rename from exercises/27-For_loop_min_value/app.py rename to exercises/09.1-For_loop_min_value/app.py diff --git a/exercises/27-For_loop_min_value/test.py b/exercises/09.1-For_loop_min_value/test.py similarity index 100% rename from exercises/27-For_loop_min_value/test.py rename to exercises/09.1-For_loop_min_value/test.py diff --git a/exercises/28-Find_avg/README.md b/exercises/10-Find_avg/README.md similarity index 100% rename from exercises/28-Find_avg/README.md rename to exercises/10-Find_avg/README.md diff --git a/exercises/28-Find_avg/app.py b/exercises/10-Find_avg/app.py similarity index 100% rename from exercises/28-Find_avg/app.py rename to exercises/10-Find_avg/app.py diff --git a/exercises/28-Find_avg/test.py b/exercises/10-Find_avg/test.py similarity index 100% rename from exercises/28-Find_avg/test.py rename to exercises/10-Find_avg/test.py diff --git a/exercises/29-Nested_listy/README.md b/exercises/11-Nested_list/README.md similarity index 100% rename from exercises/29-Nested_listy/README.md rename to exercises/11-Nested_list/README.md diff --git a/exercises/29-Nested_listy/app.py b/exercises/11-Nested_list/app.py similarity index 83% rename from exercises/29-Nested_listy/app.py rename to exercises/11-Nested_list/app.py index 0e6380fa..9c3ae4ed 100644 --- a/exercises/29-Nested_listy/app.py +++ b/exercises/11-Nested_list/app.py @@ -2,7 +2,7 @@ coordinatesArray = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]] # Your code go here: -"""from here the student hax to decleare the function""" +"""from here the student have to decleare the function""" """declare the empty variable""" # longitude = [] diff --git a/exercises/29-Nested_listy/test.py b/exercises/11-Nested_list/test.py similarity index 100% rename from exercises/29-Nested_listy/test.py rename to exercises/11-Nested_list/test.py diff --git a/exercises/12-Map_an_list/README.md b/exercises/12-Map_an_list/README.md new file mode 100644 index 00000000..09570034 --- /dev/null +++ b/exercises/12-Map_an_list/README.md @@ -0,0 +1,28 @@ +The list.map() function is one of the most used functions in Javascript. It is amazing because it lets you create a new array using each item of the original array as a seed. + +In this example, we are using the map function to create a new array of civilian hours starting from a given array of military hours. + +// Given an array of militar hours +var militaryHours = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]; + +// You first define a function that receives militaryHours and returns its equivalent in civilian time +var militaryToCivilian = function(hour){ + if(hour==12) return hour + "pm"; + else if(hour==24) return hour-12 + "am"; + else if(hour > 11) return hour-12 + "pm"; + else return hour + "am"; +} + +// you can create a new one of civilian hours by mapping the original array but passing the militaryToCivilian function to the map function +var civilianHours = militaryHours.map(militaryToCivilian); + +console.log(civilianHours); + +Copy paste the code inside the code editor to test it if you want. + +Instructions +Using the same logic given in the example, add the needed code to convert an array of Celsius values into Fahrenheit inside the map function. + +Hint +Here is a 3:40 min video explaining the array map function +https://www.youtube.com/watch?v=hfYa4ugeyuc&t=32s \ No newline at end of file diff --git a/exercises/30-Map_an_list/app.py b/exercises/12-Map_an_list/app.py similarity index 100% rename from exercises/30-Map_an_list/app.py rename to exercises/12-Map_an_list/app.py diff --git a/exercises/30-Map_an_list/test.py b/exercises/12-Map_an_list/test.py similarity index 100% rename from exercises/30-Map_an_list/test.py rename to exercises/12-Map_an_list/test.py diff --git a/exercises/30-Map_an_list/README.md b/exercises/30-Map_an_list/README.md deleted file mode 100644 index e69de29b..00000000 From 3219a0da2b3f3897f594e55e96ccc664ebac6074 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 6 Sep 2019 23:39:28 +0000 Subject: [PATCH 52/92] for loop pytest --- exercises/01.1-Access-and-Retrieve/app.py | 6 +++--- exercises/01.2-Retrieve-items/app.py | 3 ++- exercises/01.5-loop-seventeen/app.py | 2 ++ exercises/01.5-loop-seventeen/test.py | 8 +++++--- .../10.1-And_One_and_a_Two_and_a_Three/README.md | 13 +++++++++++++ exercises/10.1-And_One_and_a_Two_and_a_Three/app.py | 0 .../10.1-And_One_and_a_Two_and_a_Three/test.py | 0 7 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 exercises/10.1-And_One_and_a_Two_and_a_Three/README.md create mode 100644 exercises/10.1-And_One_and_a_Two_and_a_Three/app.py create mode 100644 exercises/10.1-And_One_and_a_Two_and_a_Three/test.py diff --git a/exercises/01.1-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py index 39ff0606..02bcae4d 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -2,9 +2,9 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here - +print(my_list[2]) #2. change 'thursday'a value here to None - +my_list[4] = None #3. print the position of step 2 - +print(my_list[4]) diff --git a/exercises/01.2-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py index d4305d84..7d46a1b3 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -1,5 +1,6 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] #output the 1st and 4th element from the list: - +print(my_list[0]) +print(my_list[3]) diff --git a/exercises/01.5-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py index 1f0aada8..24ee28ba 100644 --- a/exercises/01.5-loop-seventeen/app.py +++ b/exercises/01.5-loop-seventeen/app.py @@ -1,2 +1,4 @@ #Your code here, have fun: +for numb in range(1, 18): + print(numb) \ No newline at end of file diff --git a/exercises/01.5-loop-seventeen/test.py b/exercises/01.5-loop-seventeen/test.py index 1a79d9c9..5e326c83 100644 --- a/exercises/01.5-loop-seventeen/test.py +++ b/exercises/01.5-loop-seventeen/test.py @@ -1,12 +1,14 @@ import io import sys sys.stdout = buffer = io.StringIO() +import app import pytest -from app import my_list -@pytest.mark.it("Add ten random numbers") +@pytest.mark.it("loop from 1 to 17") def test_add_number(): - + captured = buffer.getvalue() + assert "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n" in captured + diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md new file mode 100644 index 00000000..75cf58cc --- /dev/null +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md @@ -0,0 +1,13 @@ + +Instruction +Given a contact object, please loop all its properties and values and print them on the console. +You will have to loop its properties to be able to print them + +Expected console output: +fullname : John Doe +phone : 123-123-2134 +email : test@nowhere.com + +Hints +MDN for in loop reference +https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...in_statement \ No newline at end of file diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py new file mode 100644 index 00000000..e69de29b From b18ae5a726d3f9c4c8f1575ca5ba82c68c6c3552 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 7 Sep 2019 00:15:56 +0000 Subject: [PATCH 53/92] change the numbers of exercises --- exercises/01-hello-world/README.md | 2 +- exercises/01.1-Access-and-Retrieve/README.md | 2 +- exercises/01.2-Retrieve-items/README.md | 2 +- exercises/01.3-Print-the-last-one/README.md | 2 +- exercises/01.4-Add-item-to-list/README.md | 2 +- exercises/02-Loop-list/README.md | 5 +++-- exercises/02-Loop-list/app.py | 6 +++--- exercises/02-Loop-list/test.py | 8 +++++++- exercises/02.1-Loop-from-the-top/app.py | 4 ---- exercises/02.1-Loop-from-the-top/test.py | 6 ++++++ exercises/02.2-Loop-adding-two/README.md | 5 +++-- exercises/02.2-Loop-adding-two/app.py | 5 +++-- exercises/02.2-Loop-adding-two/test.py | 5 +++++ 13 files changed, 35 insertions(+), 19 deletions(-) diff --git a/exercises/01-hello-world/README.md b/exercises/01-hello-world/README.md index effa5215..5059286b 100644 --- a/exercises/01-hello-world/README.md +++ b/exercises/01-hello-world/README.md @@ -1,4 +1,4 @@ -# `02` Hello World +# `01` Hello World In Python, we use `print` to make the computer write anything we want (the content of a variable, a given string, etc.) in something called `"the console".` diff --git a/exercises/01.1-Access-and-Retrieve/README.md b/exercises/01.1-Access-and-Retrieve/README.md index 8c40ba49..676c3e6d 100644 --- a/exercises/01.1-Access-and-Retrieve/README.md +++ b/exercises/01.1-Access-and-Retrieve/README.md @@ -1,4 +1,4 @@ -# `03` Access and retirve +# `01.1` Access and retirve # 📝Instructions from your teacher: diff --git a/exercises/01.2-Retrieve-items/README.md b/exercises/01.2-Retrieve-items/README.md index f5c6220d..9e7d9609 100644 --- a/exercises/01.2-Retrieve-items/README.md +++ b/exercises/01.2-Retrieve-items/README.md @@ -1,4 +1,4 @@ -# `04` Retrieve items +# `01.2` Retrieve items The only way of accessing a particular element in an `list`(in python), is using an index. An `index` is an integer number that represents the `position` you want to access in the list. diff --git a/exercises/01.3-Print-the-last-one/README.md b/exercises/01.3-Print-the-last-one/README.md index 30240a68..618d2ee3 100644 --- a/exercises/01.3-Print-the-last-one/README.md +++ b/exercises/01.3-Print-the-last-one/README.md @@ -1,4 +1,4 @@ -# `05` Print the last one +# `01.3` Print the last one You will never know how many `items` my_stupid_list has because it is being `randomly` generated during runtime. diff --git a/exercises/01.4-Add-item-to-list/README.md b/exercises/01.4-Add-item-to-list/README.md index 8f893eac..1c279e95 100644 --- a/exercises/01.4-Add-item-to-list/README.md +++ b/exercises/01.4-Add-item-to-list/README.md @@ -1,4 +1,4 @@ -# `06` Add items to the list +# `01.4` Add items to the list # 📝Instructions 1. Add 10 random integers to the "arr" list. diff --git a/exercises/02-Loop-list/README.md b/exercises/02-Loop-list/README.md index 4588deb7..cdcd6c16 100644 --- a/exercises/02-Loop-list/README.md +++ b/exercises/02-Loop-list/README.md @@ -1,6 +1,7 @@ -# `08` Instructions from your teacher: +# `08` Loop list -The code right now is `printing the first item in the console.` +# Instructions from your teacher: +The code right now is printing the first item in the console. Instead of doing that, print `all the elements` in the list. ```py You will have to loop through the whole array using a for loop. diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index 6c3dcbf1..5805d932 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,9 +1,9 @@ -my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55,33,435,4,6,54,63,45,4,67,56,47,1,34,54,32,54,1,78,98,0,9,8,98,76,7,54,2,3,42,456,4,3321,5] +my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55] #You don't to change nothing above, your code go below: - -print(my_list[0]) +for x in my_list: + print(x) diff --git a/exercises/02-Loop-list/test.py b/exercises/02-Loop-list/test.py index 9e119350..c12bb291 100644 --- a/exercises/02-Loop-list/test.py +++ b/exercises/02-Loop-list/test.py @@ -2,7 +2,13 @@ import sys sys.stdout = buffer = io.StringIO() -from app import my_list + + import pytest +import app +@pytest.mark.it("Print the all items from the list") +def test_output(): + captured = buffer.getvalue() + assert "232\n32\n14\n55\n4\n3\n32\n3\n24\n5\n5\n5\n34\n2\n35\n5365743\n52\n34\n3\n55\n" in captured diff --git a/exercises/02.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py index 1741efa4..83e9b65d 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -6,7 +6,3 @@ for i in range(len(my_sample_list)): print(my_sample_list[-i-1]) - -for i in reversed(my_sample_list): - print(i) - diff --git a/exercises/02.1-Loop-from-the-top/test.py b/exercises/02.1-Loop-from-the-top/test.py index 07b99521..a3d2b435 100644 --- a/exercises/02.1-Loop-from-the-top/test.py +++ b/exercises/02.1-Loop-from-the-top/test.py @@ -4,3 +4,9 @@ from app import my_sample_list import pytest +import app + +@pytest.mark.it("loop from the last") +def test_output(): + captured = buffer.getvalue() + assert "12\n25\n23\n55\n56432\n48\n23\n867543\n8\n654\n47889\n4\n5\n3423\n" in captured diff --git a/exercises/02.2-Loop-adding-two/README.md b/exercises/02.2-Loop-adding-two/README.md index 4695fefa..b8f54732 100644 --- a/exercises/02.2-Loop-adding-two/README.md +++ b/exercises/02.2-Loop-adding-two/README.md @@ -1,5 +1,6 @@ -# `10` Instructions from your teacher: -```js +# `10` Loop adding two + +```py This code is `looping` the whole array, `one by one`. ``` diff --git a/exercises/02.2-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py index f328c488..72efc9e9 100644 --- a/exercises/02.2-Loop-adding-two/app.py +++ b/exercises/02.2-Loop-adding-two/app.py @@ -6,6 +6,7 @@ for i in range(0, len(my_sample_list), 2): print(my_sample_list[i]) +# # for i in my_sample_list[0::2]: +# # print(i) -for i in my_sample_list[0::2]: - print(i) \ No newline at end of file +# print(my_sample_list[::2]) \ No newline at end of file diff --git a/exercises/02.2-Loop-adding-two/test.py b/exercises/02.2-Loop-adding-two/test.py index 794503d8..195a6c6c 100644 --- a/exercises/02.2-Loop-adding-two/test.py +++ b/exercises/02.2-Loop-adding-two/test.py @@ -4,5 +4,10 @@ from app import my_sample_list import pytest +import app +@pytest.mark.it("Loop two by two") +def test_output(): + captured = buffer.getvalue() + assert "3423\n4\n654\n867543\n48\n55\n25\n" in captured From 026e2e39bfc83fe0fa56c70ffcfee09da3d71499 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 7 Sep 2019 01:04:04 +0000 Subject: [PATCH 54/92] test exercises --- exercises/01-hello-world/app.py | 1 - exercises/01-hello-world/test.py | 32 +++++++++++++--------- exercises/01.5-loop-seventeen/README.md | 2 +- exercises/01.5-loop-seventeen/app.py | 3 +- exercises/01.5-loop-seventeen/test.py | 17 +++++++++--- exercises/02-Loop-list/README.md | 2 +- exercises/02.1-Loop-from-the-top/README.md | 2 +- 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py index 9b473b3c..8489699e 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,4 +1,3 @@ #You have to print `hello` in the console, your code go here: - print("hello") diff --git a/exercises/01-hello-world/test.py b/exercises/01-hello-world/test.py index 11be726b..03d03d8a 100644 --- a/exercises/01-hello-world/test.py +++ b/exercises/01-hello-world/test.py @@ -2,21 +2,27 @@ import sys sys.stdout = buffer = io.StringIO() -from app import my_function +# from app import my_function import pytest +import app -@pytest.mark.it('Your code needs to print hello on the console') -def test_for_file_output(capsys): - captured = buffer.getvalue() - assert captured == "hello\n" #add \n because the console jumps the line on every print +# @pytest.mark.it('Your code needs to print hello on the console') +# def test_for_file_output(capsys): +# captured = buffer.getvalue() +# assert captured == "hello\n" #add \n because the console jumps the line on every print -@pytest.mark.it('Your function needs to print "Hello Inside Function" on the console') -def test_for_function_output(capsys): - my_function() - captured = capsys.readouterr() - assert captured.out == "Hello Inside Function\n" +# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console') +# def test_for_function_output(capsys): +# my_function() +# captured = capsys.readouterr() +# assert captured.out == "Hello Inside Function\n" -@pytest.mark.it('Your function needs to return True') -def test_for_function_return(capsys): - assert my_function() == True +# @pytest.mark.it('Your function needs to return True') +# def test_for_function_return(capsys): +# assert my_function() == True +@pytest.mark.it("Output 'Hello'") +def test_output(): + captured = buffer.getvalue() + assert "hello\n" in captured + # convert everything in the buffer to lower case, captured to lower case \ No newline at end of file diff --git a/exercises/01.5-loop-seventeen/README.md b/exercises/01.5-loop-seventeen/README.md index 7c5e42f9..2f57e907 100644 --- a/exercises/01.5-loop-seventeen/README.md +++ b/exercises/01.5-loop-seventeen/README.md @@ -1,4 +1,4 @@ -# `07` Loop from 1 to 17 +# `01.5` Loop from 1 to 17 # 📝Instructions from your teacher: 1. Count from 1 to 17 with a loop and print each number on the console. diff --git a/exercises/01.5-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py index 24ee28ba..ec89829b 100644 --- a/exercises/01.5-loop-seventeen/app.py +++ b/exercises/01.5-loop-seventeen/app.py @@ -1,4 +1,3 @@ #Your code here, have fun: -for numb in range(1, 18): - print(numb) \ No newline at end of file + diff --git a/exercises/01.5-loop-seventeen/test.py b/exercises/01.5-loop-seventeen/test.py index 5e326c83..c6fe9b06 100644 --- a/exercises/01.5-loop-seventeen/test.py +++ b/exercises/01.5-loop-seventeen/test.py @@ -1,14 +1,23 @@ import io import sys sys.stdout = buffer = io.StringIO() -import app - +import os import pytest +import app -@pytest.mark.it("loop from 1 to 17") -def test_add_number(): +@pytest.mark.it("Output from 1 to 17") +def test_output(): captured = buffer.getvalue() assert "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n" in captured + + +@pytest.mark.it("Make sure that there is a 'for loop' in your code") +def test_for_loop(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for ") > 0 diff --git a/exercises/02-Loop-list/README.md b/exercises/02-Loop-list/README.md index cdcd6c16..839ab8f9 100644 --- a/exercises/02-Loop-list/README.md +++ b/exercises/02-Loop-list/README.md @@ -1,4 +1,4 @@ -# `08` Loop list +# `02` Loop list # Instructions from your teacher: The code right now is printing the first item in the console. diff --git a/exercises/02.1-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md index 6639b4e1..8688e965 100644 --- a/exercises/02.1-Loop-from-the-top/README.md +++ b/exercises/02.1-Loop-from-the-top/README.md @@ -1,4 +1,4 @@ -# `09` Instructions from your teacher: +# `02.1` Instructions from your teacher: ```js This loop is `looping` the list from beginning to end... increasing one by one. ``` From 8b30200f8b4d255073836c6c9a322ce7e386d7ac Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 9 Sep 2019 22:51:59 +0000 Subject: [PATCH 55/92] readmes --- exercises/00-welcome/README.md | 6 ++++++ exercises/01.3-Print-the-last-one/app.py | 1 + exercises/01.3-Print-the-last-one/test.py | 2 +- exercises/01.4-Add-item-to-list/test.py | 8 +++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/exercises/00-welcome/README.md b/exercises/00-welcome/README.md index aac09713..7c26e75b 100644 --- a/exercises/00-welcome/README.md +++ b/exercises/00-welcome/README.md @@ -1,2 +1,8 @@ # Welcome to Python! +Welcome to the Python repl.it at 4Geeks Academy!!! + + + +!["Welcome to python repl.it at 4Geeks Academy!!!"](https://i.udemycdn.com/course/750x422/95568_9c21_6.jpg) + diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index ec34c20d..682e7fa4 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -1,3 +1,4 @@ +#You have to import random function import random def generate_random_list(): diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index 89f8ab19..e52f7739 100644 --- a/exercises/01.3-Print-the-last-one/test.py +++ b/exercises/01.3-Print-the-last-one/test.py @@ -15,4 +15,4 @@ def test_create_assign(): @pytest.mark.it("print in the console the_last_one") def test_output(): captured = buffer.getvalue() - assert str(app.the_last_one) in captured + assert print(app.the_last_one) in captured diff --git a/exercises/01.4-Add-item-to-list/test.py b/exercises/01.4-Add-item-to-list/test.py index c171d6b1..70084e63 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -5,7 +5,13 @@ import pytest import app import random +from app import my_list @pytest.mark.it("Add ten random numbers to the list") def test_add_numb(): - assert app.my_list.append(random.randint(1, 10)) \ No newline at end of file + assert app.my_list.append(random.randint(1, 10)) + +@pytest.mark.it("Output of the list with 15 items numbers") +def test_output(): + captured = buffer.getvalue() + assert str(app.my_list) in captured \ No newline at end of file From e830d89781b7341898fbaa2629a6066bfd7c5803 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 9 Sep 2019 23:09:36 +0000 Subject: [PATCH 56/92] 10.1 exercises --- .../10.1-And_One_and_a_Two_and_a_Three/README.md | 14 ++++++++------ .../10.1-And_One_and_a_Two_and_a_Three/app.py | 11 +++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md index 75cf58cc..4ee9938b 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md @@ -1,13 +1,15 @@ +# `10.1` And one and two and three +# 📝Instruction +1. Given a contact object, please `loop all its properties and values` and print them on the console. +2. You will have to loop its properties to be able to print them -Instruction -Given a contact object, please loop all its properties and values and print them on the console. -You will have to loop its properties to be able to print them - +```py Expected console output: fullname : John Doe phone : 123-123-2134 email : test@nowhere.com +``` -Hints +💡Hints MDN for in loop reference -https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Loops_and_iteration#for...in_statement \ No newline at end of file + \ No newline at end of file diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py index e69de29b..fc90734d 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -0,0 +1,11 @@ +contact = { + "fullname": "Jane Doe", + "phone": "321-321-4321", + "email": "test@test.com" +} +#Your code here: + +# declare and aux variable and assign the value of the key + + +# loop the entire dict and concactenate the items in one output \ No newline at end of file From e1eb9cd83376ce82d4489d508a1d0adab386fdb0 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Mon, 9 Sep 2019 23:20:25 +0000 Subject: [PATCH 57/92] loop dict iteration --- .../10.1-And_One_and_a_Two_and_a_Three/app.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py index fc90734d..7783c82f 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -6,6 +6,20 @@ #Your code here: # declare and aux variable and assign the value of the key +k = contact.keys() -# loop the entire dict and concactenate the items in one output \ No newline at end of file +# loop the entire dict and concactenate the items in one output +for k, v in contact.items(): + print("{0}: {1}".format(k, v)) + + +#another form: +x = contact.keys() + +for x, e in contact.items(): + print(x, ":", e) + +#loop without declaration: +for key, value in contact.items(): + print(key, ":", value) \ No newline at end of file From b584348cda2026e09b14b41137c037808e4ab3d2 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 00:52:50 +0000 Subject: [PATCH 58/92] 12.1 exercise --- exercises/12-Map_an_list/README.md | 26 -------------------------- exercises/12-Map_an_list/app.py | 15 +++++++++++++++ exercises/12.1_more_mapping/README.md | 16 ++++++++++++++++ exercises/12.1_more_mapping/app.py | 16 ++++++++++++++++ exercises/12.1_more_mapping/test.py | 0 5 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 exercises/12.1_more_mapping/README.md create mode 100644 exercises/12.1_more_mapping/app.py create mode 100644 exercises/12.1_more_mapping/test.py diff --git a/exercises/12-Map_an_list/README.md b/exercises/12-Map_an_list/README.md index 09570034..139597f9 100644 --- a/exercises/12-Map_an_list/README.md +++ b/exercises/12-Map_an_list/README.md @@ -1,28 +1,2 @@ -The list.map() function is one of the most used functions in Javascript. It is amazing because it lets you create a new array using each item of the original array as a seed. -In this example, we are using the map function to create a new array of civilian hours starting from a given array of military hours. -// Given an array of militar hours -var militaryHours = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24]; - -// You first define a function that receives militaryHours and returns its equivalent in civilian time -var militaryToCivilian = function(hour){ - if(hour==12) return hour + "pm"; - else if(hour==24) return hour-12 + "am"; - else if(hour > 11) return hour-12 + "pm"; - else return hour + "am"; -} - -// you can create a new one of civilian hours by mapping the original array but passing the militaryToCivilian function to the map function -var civilianHours = militaryHours.map(militaryToCivilian); - -console.log(civilianHours); - -Copy paste the code inside the code editor to test it if you want. - -Instructions -Using the same logic given in the example, add the needed code to convert an array of Celsius values into Fahrenheit inside the map function. - -Hint -Here is a 3:40 min video explaining the array map function -https://www.youtube.com/watch?v=hfYa4ugeyuc&t=32s \ No newline at end of file diff --git a/exercises/12-Map_an_list/app.py b/exercises/12-Map_an_list/app.py index e69de29b..326fd4c3 100644 --- a/exercises/12-Map_an_list/app.py +++ b/exercises/12-Map_an_list/app.py @@ -0,0 +1,15 @@ +Celsius_values = [-2,34,56,-10] + +result = map(lambda x : x * 5 / 9 + 32, Celsius_values) +fahrenheit_values = set(result) +print(fahrenheit_values) + + + + +def fahrenheit_values(x): + return x * 5/9 + 32 +Celsius_values = [-2,34,56,-10] +result = map(fahrenheit_values, Celsius_values) +total = set(result) +print(total) diff --git a/exercises/12.1_more_mapping/README.md b/exercises/12.1_more_mapping/README.md new file mode 100644 index 00000000..d90cfcf2 --- /dev/null +++ b/exercises/12.1_more_mapping/README.md @@ -0,0 +1,16 @@ + +myNumbers = [23,234,345,4356234,243,43,56,2] + +result = map(lambda x: x * 3, myNumbers) +total = set(result) +print(total) + + + +def other_sample(x): + return x * 3 + +myNumbers = [23,234,345,4356234,243,43,56,2] +result = map(other_sample, myNumbers) +total = set(result) +print(total) diff --git a/exercises/12.1_more_mapping/app.py b/exercises/12.1_more_mapping/app.py new file mode 100644 index 00000000..a1df7ce3 --- /dev/null +++ b/exercises/12.1_more_mapping/app.py @@ -0,0 +1,16 @@ +myNumbers = [23,234,345,4356234,243,43,56,2] + +result = map(lambda x: x * 3, myNumbers) +total = set(result) +print(total) + + + +# other sample +def other_sample(x): + return x * 3 + +myNumbers = [23,234,345,4356234,243,43,56,2] +result = map(other_sample, myNumbers) +total = set(result) +print(total) diff --git a/exercises/12.1_more_mapping/test.py b/exercises/12.1_more_mapping/test.py new file mode 100644 index 00000000..e69de29b From 292532866d5366d0af0d193af7ddcc9add8c601d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 01:12:47 +0000 Subject: [PATCH 59/92] 12.2 map function inside --- exercises/12.1_more_mapping/README.md | 32 +++++++++++++------ .../README.md | 14 ++++++++ .../12.2-Map_function_inside_variable/app.py | 7 ++++ .../12.2-Map_function_inside_variable/test.py | 0 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 exercises/12.2-Map_function_inside_variable/README.md create mode 100644 exercises/12.2-Map_function_inside_variable/app.py create mode 100644 exercises/12.2-Map_function_inside_variable/test.py diff --git a/exercises/12.1_more_mapping/README.md b/exercises/12.1_more_mapping/README.md index d90cfcf2..0be12c65 100644 --- a/exercises/12.1_more_mapping/README.md +++ b/exercises/12.1_more_mapping/README.md @@ -1,16 +1,28 @@ +# `12.1` More mapping -myNumbers = [23,234,345,4356234,243,43,56,2] -result = map(lambda x: x * 3, myNumbers) -total = set(result) -print(total) +The list `map` method calls a function for each value in a +list and then outputs a new list with the modified values. +```py + +def values_list(number) { + return number + 1; +} + +my_list = [1, 2, 3, 4] +result = map(values_list,my_list) +``` + +# 📝Instructions: + +1. Create a function named increment_by_one that will multiply each number by 3. +2. Use the list map() function to run the increment_by_one function through each value in the list. +3. Store the new list in a variable named total and print() the new list. + +💡Hint: +The function will take a parameter with the original item being transformed and added into the new list. +Remember that your function must return each of the new items to be stored into the new list. -def other_sample(x): - return x * 3 -myNumbers = [23,234,345,4356234,243,43,56,2] -result = map(other_sample, myNumbers) -total = set(result) -print(total) diff --git a/exercises/12.2-Map_function_inside_variable/README.md b/exercises/12.2-Map_function_inside_variable/README.md new file mode 100644 index 00000000..bf532d33 --- /dev/null +++ b/exercises/12.2-Map_function_inside_variable/README.md @@ -0,0 +1,14 @@ +# `12.2` Map function inside of variable + +The variable names contains a lot of names (dugh...) + +The function stored in the variable prepender returns whatever is passed to it + but prepended with the string: 'My name is:' + +#📝Instructions +1. Please map the names list using the prepender function to create a new list that looks like this: +!["Map function"](https://storage.googleapis.com/replit/images/1525912878195_89876a082d32ee32bb7a1ab5834dbca0.pn) + + +💡Hint: +It's one line of code, pass the function to the map! \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py new file mode 100644 index 00000000..ece16e5e --- /dev/null +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -0,0 +1,7 @@ +names = ['Alice','Bob','Marry','Joe','Hilary','Stevia','Dylan'] + +def prepender(name): + return "My name is: " + name +result = map(prepender, names) +my_names = set(result) +print(my_names) diff --git a/exercises/12.2-Map_function_inside_variable/test.py b/exercises/12.2-Map_function_inside_variable/test.py new file mode 100644 index 00000000..e69de29b From 8d3768ff0bd4808a7a54fd15fee8e7b1f83a64e9 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 03:15:57 +0000 Subject: [PATCH 60/92] readmes --- exercises/12.3-Map_data_types/README.md | 15 ++++++++++++ exercises/12.3-Map_data_types/app.py | 16 +++++++++++++ exercises/12.3-Map_data_types/test.py | 0 exercises/12.4-Map_list_of_objects/README.md | 24 ++++++++++++++++++++ exercises/12.4-Map_list_of_objects/app.py | 0 exercises/12.4-Map_list_of_objects/test.py | 0 exercises/12.5-Yes_and_no/README.md | 0 exercises/12.5-Yes_and_no/app.py | 0 exercises/12.5-Yes_and_no/test.py | 0 9 files changed, 55 insertions(+) create mode 100644 exercises/12.3-Map_data_types/README.md create mode 100644 exercises/12.3-Map_data_types/app.py create mode 100644 exercises/12.3-Map_data_types/test.py create mode 100644 exercises/12.4-Map_list_of_objects/README.md create mode 100644 exercises/12.4-Map_list_of_objects/app.py create mode 100644 exercises/12.4-Map_list_of_objects/test.py create mode 100644 exercises/12.5-Yes_and_no/README.md create mode 100644 exercises/12.5-Yes_and_no/app.py create mode 100644 exercises/12.5-Yes_and_no/test.py diff --git a/exercises/12.3-Map_data_types/README.md b/exercises/12.3-Map_data_types/README.md new file mode 100644 index 00000000..ec9dd552 --- /dev/null +++ b/exercises/12.3-Map_data_types/README.md @@ -0,0 +1,15 @@ +#`12.3` Map data types +Some times lists come with mixed values and you need to unify them into only one data type. + +#📝Instructions +Update the map function to make it create a new list that contains the data +types of each corresponding item from the original list. + +The result in the console should be something like: +```py +[string,string,... ,number,string,...] +``` + +💡Hint: +Use the type() function to get the data type +more about data type: https://www.w3schools.com/python/python_datatypes.asp \ No newline at end of file diff --git a/exercises/12.3-Map_data_types/app.py b/exercises/12.3-Map_data_types/app.py new file mode 100644 index 00000000..1dd837c4 --- /dev/null +++ b/exercises/12.3-Map_data_types/app.py @@ -0,0 +1,16 @@ + +def my_function(items): + return type(items) + +list_of_Strings = ['1','5','45','34','343','34',6556,323] +result = map(my_function, list_of_Strings) +sample = set(result) +print(sample) + + +#this return the same +list_of_Strings = ['1','5','45','34','343','34',6556,323] +other = map(lambda item: type(item), list_of_Strings) +sample = set(other) +print(sample) + diff --git a/exercises/12.3-Map_data_types/test.py b/exercises/12.3-Map_data_types/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.4-Map_list_of_objects/README.md b/exercises/12.4-Map_list_of_objects/README.md new file mode 100644 index 00000000..65cad718 --- /dev/null +++ b/exercises/12.4-Map_list_of_objects/README.md @@ -0,0 +1,24 @@ +#`12.4` Map list of objects + +The most common scenario for the mapping function is for simplifying given lists, for example: + +The current algorithm creates a lists with only the names of the people and prints it on the console. + +#📝Instructions + +1. Please update the mapping function so it creates a list where each item contains the following: + +Hello my name is Joe and I am 13 years old. + +💡Hint +You have to get the age of each people based on their birthDate. Search in Google "How to get the age of given birth date in python" +Inside your simplifier function you have to return a concatenation. + +The expected output should look similar but not exactly to this: + +[ 'Hello, my name is Joe and I am 32 years old', + 'Hello, my name is Bob and I am 42 years old', + 'Hello, my name is Erika and I am 28 years old', + 'Hello, my name is Dylan and I am 18 years old', + 'Hello, my name is Steve and I am 14 years old' ] + diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.4-Map_list_of_objects/test.py b/exercises/12.4-Map_list_of_objects/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.5-Yes_and_no/README.md b/exercises/12.5-Yes_and_no/README.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.5-Yes_and_no/app.py b/exercises/12.5-Yes_and_no/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.5-Yes_and_no/test.py b/exercises/12.5-Yes_and_no/test.py new file mode 100644 index 00000000..e69de29b From 29b696d3c95736af99466e1061043c597446d3ff Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 03:26:23 +0000 Subject: [PATCH 61/92] 13 --- exercises/12.6-Transformers/README.md | 0 exercises/12.6-Transformers/app.py | 0 exercises/12.6-Transformers/test.py | 0 exercises/13-Filter_list/README.md | 0 exercises/13-Filter_list/app.py | 17 +++++++++++++++++ exercises/13-Filter_list/test.py | 0 6 files changed, 17 insertions(+) create mode 100644 exercises/12.6-Transformers/README.md create mode 100644 exercises/12.6-Transformers/app.py create mode 100644 exercises/12.6-Transformers/test.py create mode 100644 exercises/13-Filter_list/README.md create mode 100644 exercises/13-Filter_list/app.py create mode 100644 exercises/13-Filter_list/test.py diff --git a/exercises/12.6-Transformers/README.md b/exercises/12.6-Transformers/README.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/12.6-Transformers/test.py b/exercises/12.6-Transformers/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13-Filter_list/README.md b/exercises/13-Filter_list/README.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13-Filter_list/app.py b/exercises/13-Filter_list/app.py new file mode 100644 index 00000000..c0ac145f --- /dev/null +++ b/exercises/13-Filter_list/app.py @@ -0,0 +1,17 @@ +allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] + +result = filter(lambda x: x > 10, allNumbers) +total = set(result) +print(total) + + + + +#the same result +def sample(items): + return items > 10 + +other_list = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] +return_list = filter(sample, other_list) +aux = set(return_list) +print(aux) \ No newline at end of file diff --git a/exercises/13-Filter_list/test.py b/exercises/13-Filter_list/test.py new file mode 100644 index 00000000..e69de29b From bf7029058e2400dcbdb7aee45e97093d838447cf Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 04:01:28 +0000 Subject: [PATCH 62/92] 13.2 readme --- exercises/13-Filter_list/README.md | 17 ++++++++++++++++ exercises/13.1-Filter_list/README.md | 23 ++++++++++++++++++++++ exercises/13.1-Filter_list/app.py | 6 ++++++ exercises/13.1-Filter_list/test.py | 0 exercises/13.2-filter_done_tasks/README.md | 12 +++++++++++ exercises/13.2-filter_done_tasks/app.py | 0 exercises/13.2-filter_done_tasks/test.py | 0 7 files changed, 58 insertions(+) create mode 100644 exercises/13.1-Filter_list/README.md create mode 100644 exercises/13.1-Filter_list/app.py create mode 100644 exercises/13.1-Filter_list/test.py create mode 100644 exercises/13.2-filter_done_tasks/README.md create mode 100644 exercises/13.2-filter_done_tasks/app.py create mode 100644 exercises/13.2-filter_done_tasks/test.py diff --git a/exercises/13-Filter_list/README.md b/exercises/13-Filter_list/README.md index e69de29b..68cbd561 100644 --- a/exercises/13-Filter_list/README.md +++ b/exercises/13-Filter_list/README.md @@ -0,0 +1,17 @@ +#`13` Filter list + +Another looping function that is available on python is the `filter function`. + +Its main purpose is to remove elements from the original list and return a new list with the result. + +The code on the left is filtering the odd numbers from the allNumbers list. + +#📝Instructions + +1. Please update the filtering function so it filters all the numbers bigger than 10. + +```py +Expected output: + +[ 23, 12, 35, 54, 21, 534, 23, 42 ] +``` \ No newline at end of file diff --git a/exercises/13.1-Filter_list/README.md b/exercises/13.1-Filter_list/README.md new file mode 100644 index 00000000..7134ff06 --- /dev/null +++ b/exercises/13.1-Filter_list/README.md @@ -0,0 +1,23 @@ +#`13.1` Filter list + +this is another example using filter list in python + +For example, this algorithm filters the allNumbers list and returns a new list with only the odds numbers: + +```py +allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] + +result = filter(lambda x: x % 2 > 0, allNumbers) +return_list = set(result) +print(return_list) +``` + + + +#📝Instructions +1. Complete the code to make it fill the resultingNames list with only the names that start with letter R +2. Use the filter function + + \ No newline at end of file diff --git a/exercises/13.1-Filter_list/app.py b/exercises/13.1-Filter_list/app.py new file mode 100644 index 00000000..9646097a --- /dev/null +++ b/exercises/13.1-Filter_list/app.py @@ -0,0 +1,6 @@ +#using lambda +allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] + +result = filter(lambda x: x.startswith("R"), allNames) +return_list = set(result) +print(return_list) diff --git a/exercises/13.1-Filter_list/test.py b/exercises/13.1-Filter_list/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13.2-filter_done_tasks/README.md b/exercises/13.2-filter_done_tasks/README.md new file mode 100644 index 00000000..7a7b63e3 --- /dev/null +++ b/exercises/13.2-filter_done_tasks/README.md @@ -0,0 +1,12 @@ +#`13.2` Filter done tasks + +# Instructions +1. Use the filter function to remove all the undone tasks from the tasks list and print the new list on the console. + +```py +Expected output: + +[ { label: 'Eat my lunch', done: true }, + { label: 'Replit the finishes', done: true }, + { label: 'Read a book', done: true } ] + ``` \ No newline at end of file diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13.2-filter_done_tasks/test.py b/exercises/13.2-filter_done_tasks/test.py new file mode 100644 index 00000000..e69de29b From fb28fdf8607cf6737cc639d0a453df3bac3b4013 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 22:28:28 +0000 Subject: [PATCH 63/92] 13.3 filter list strings --- .../README.md | 0 .../app.py | 0 .../test.py | 0 exercises/13.3-Filter_list_strings/README.md | 0 exercises/13.3-Filter_list_strings/app.py | 0 exercises/13.3-Filter_list_strings/test.py | 13 +++++++++++++ 6 files changed, 13 insertions(+) rename exercises/{13.1-Filter_list => 13.1-Filter_and_list}/README.md (100%) rename exercises/{13.1-Filter_list => 13.1-Filter_and_list}/app.py (100%) rename exercises/{13.1-Filter_list => 13.1-Filter_and_list}/test.py (100%) create mode 100644 exercises/13.3-Filter_list_strings/README.md create mode 100644 exercises/13.3-Filter_list_strings/app.py create mode 100644 exercises/13.3-Filter_list_strings/test.py diff --git a/exercises/13.1-Filter_list/README.md b/exercises/13.1-Filter_and_list/README.md similarity index 100% rename from exercises/13.1-Filter_list/README.md rename to exercises/13.1-Filter_and_list/README.md diff --git a/exercises/13.1-Filter_list/app.py b/exercises/13.1-Filter_and_list/app.py similarity index 100% rename from exercises/13.1-Filter_list/app.py rename to exercises/13.1-Filter_and_list/app.py diff --git a/exercises/13.1-Filter_list/test.py b/exercises/13.1-Filter_and_list/test.py similarity index 100% rename from exercises/13.1-Filter_list/test.py rename to exercises/13.1-Filter_and_list/test.py diff --git a/exercises/13.3-Filter_list_strings/README.md b/exercises/13.3-Filter_list_strings/README.md new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13.3-Filter_list_strings/test.py b/exercises/13.3-Filter_list_strings/test.py new file mode 100644 index 00000000..8b56ff83 --- /dev/null +++ b/exercises/13.3-Filter_list_strings/test.py @@ -0,0 +1,13 @@ +names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] + + + +def list_names(word): + if 'am' in word: + return True + else: + return False + +result = filter(list_names, names) +my_names = set(result) +print(my_names) From 46ac8dc6b6f2eccd9a457c92ba116a9c3755069d Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 10 Sep 2019 22:52:02 +0000 Subject: [PATCH 64/92] filter function 13.1 --- exercises/13.1-Filter_and_list/app.py | 13 +++++++++++++ exercises/13.3-Filter_list_strings/README.md | 9 +++++++++ exercises/13.3-Filter_list_strings/app.py | 18 ++++++++++++++++++ exercises/13.3-Filter_list_strings/test.py | 13 ------------- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/exercises/13.1-Filter_and_list/app.py b/exercises/13.1-Filter_and_list/app.py index 9646097a..42c47dd8 100644 --- a/exercises/13.1-Filter_and_list/app.py +++ b/exercises/13.1-Filter_and_list/app.py @@ -4,3 +4,16 @@ result = filter(lambda x: x.startswith("R"), allNames) return_list = set(result) print(return_list) + + +#the same result +def my_function(names): + if 'R' in names: + return True + else: + return False + +my_filter_function = filter(my_function, allNames) +result = set(my_filter_function) +print(result) + diff --git a/exercises/13.3-Filter_list_strings/README.md b/exercises/13.3-Filter_list_strings/README.md index e69de29b..ff44b270 100644 --- a/exercises/13.3-Filter_list_strings/README.md +++ b/exercises/13.3-Filter_list_strings/README.md @@ -0,0 +1,9 @@ +#`13.3` Filter list string + +#📝Instructions: + +1. Given a list names please create a function filters the list with only the names that contain the given string. +2. Create a function called filteringList that take two values one is the list and second one is the filter desire. +3. The search should NOT be Case Sensitive. + + diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index e69de29b..60dd52fe 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -0,0 +1,18 @@ +names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] + + + +def filteringList(word): + if 'am' in word: + return True + else: + return False + +result = filter(filteringList, names) +my_names = set(result) +print(my_names) + + + +result = [s for s in names if 'am' in s] +print(result) \ No newline at end of file diff --git a/exercises/13.3-Filter_list_strings/test.py b/exercises/13.3-Filter_list_strings/test.py index 8b56ff83..e69de29b 100644 --- a/exercises/13.3-Filter_list_strings/test.py +++ b/exercises/13.3-Filter_list_strings/test.py @@ -1,13 +0,0 @@ -names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] - - - -def list_names(word): - if 'am' in word: - return True - else: - return False - -result = filter(list_names, names) -my_names = set(result) -print(my_names) From 930b482052be3f98dc0f3e0506af1145d35ce3fb Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 00:18:35 +0000 Subject: [PATCH 65/92] 12.6 transformers --- exercises/12.6-Transformers/app.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py index e69de29b..42700aa8 100644 --- a/exercises/12.6-Transformers/app.py +++ b/exercises/12.6-Transformers/app.py @@ -0,0 +1,19 @@ +incomingAJAXData = [ + { "name": 'Mario', "lastName": 'Montes' }, + { "name": 'Joe', "lastName": 'Biden' }, + { "name": 'Bill', "lastName": 'Clon' }, + { "name": 'Hilary', "lastName": 'Mccafee' }, + { "name": 'Bobby', "lastName": 'Mc birth' } +] + +#return the dict into the list +all_people = list(map(lambda p: p["name"] + " " + p["lastName"], incomingAJAXData)) +print(all_people) + +#function return dict into the list +def my_function(items): + return items['name'] +' '+items['lastName'] + +result = list(map(my_function, incomingAJAXData)) +sample = set(result) +print(sample) From c6578e9a3ca70d3517ac93f056360920278859eb Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 04:13:56 +0000 Subject: [PATCH 66/92] 12.3 data type --- exercises/12.3-Map_data_types/app.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/exercises/12.3-Map_data_types/app.py b/exercises/12.3-Map_data_types/app.py index 1dd837c4..8713429d 100644 --- a/exercises/12.3-Map_data_types/app.py +++ b/exercises/12.3-Map_data_types/app.py @@ -1,16 +1,15 @@ +list_of_Strings = ['1','5','45','34','343','34',6556,323] -def my_function(items): - return type(items) -list_of_Strings = ['1','5','45','34','343','34',6556,323] -result = map(my_function, list_of_Strings) -sample = set(result) -print(sample) +def type_list(items): + return type(items) + +result = list(map(type_list, list_Strings)) +print(result) #this return the same -list_of_Strings = ['1','5','45','34','343','34',6556,323] -other = map(lambda item: type(item), list_of_Strings) -sample = set(other) +type_data = lambda data: (type(data)) +sample = list(map(type_data, list_Strings)) print(sample) From 241e1a51cbe7cde3f1dc3e1833a682f7d8c0287e Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 04:19:52 +0000 Subject: [PATCH 67/92] 12 map and list --- exercises/12-Map_an_list/app.py | 11 ++++------- exercises/12.1_more_mapping/app.py | 12 +++++------- exercises/12.2-Map_function_inside_variable/app.py | 5 ++--- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/exercises/12-Map_an_list/app.py b/exercises/12-Map_an_list/app.py index 326fd4c3..31061ac0 100644 --- a/exercises/12-Map_an_list/app.py +++ b/exercises/12-Map_an_list/app.py @@ -1,15 +1,12 @@ Celsius_values = [-2,34,56,-10] -result = map(lambda x : x * 5 / 9 + 32, Celsius_values) -fahrenheit_values = set(result) +fahrenheit_values = list(map(lambda x : x * 5 / 9 + 32, Celsius_values)) print(fahrenheit_values) -def fahrenheit_values(x): +def fahrenheitValues(x): return x * 5/9 + 32 -Celsius_values = [-2,34,56,-10] -result = map(fahrenheit_values, Celsius_values) -total = set(result) -print(total) +result = list(map(fahrenheit_values, Celsius_values)) +print(result) diff --git a/exercises/12.1_more_mapping/app.py b/exercises/12.1_more_mapping/app.py index a1df7ce3..e3da93ea 100644 --- a/exercises/12.1_more_mapping/app.py +++ b/exercises/12.1_more_mapping/app.py @@ -1,8 +1,8 @@ myNumbers = [23,234,345,4356234,243,43,56,2] -result = map(lambda x: x * 3, myNumbers) -total = set(result) -print(total) + +result = list(map(lambda x: x * 3, myNumbers)) +print(result) @@ -10,7 +10,5 @@ def other_sample(x): return x * 3 -myNumbers = [23,234,345,4356234,243,43,56,2] -result = map(other_sample, myNumbers) -total = set(result) -print(total) +result = list(map(other_sample, myNumbers)) +print(result) diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index ece16e5e..7398239b 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -2,6 +2,5 @@ def prepender(name): return "My name is: " + name -result = map(prepender, names) -my_names = set(result) -print(my_names) +result = list(map(prepender, names)) +print(result) From dd96ef776758c5219e53f70c575d08af04b01650 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 04:31:02 +0000 Subject: [PATCH 68/92] 12.5 yes and no --- .../{12-Map_an_list => 12-Map_and_list}/README.md | 0 .../{12-Map_an_list => 12-Map_and_list}/app.py | 0 .../{12-Map_an_list => 12-Map_and_list}/test.py | 0 exercises/12.4-Map_list_of_objects/app.py | 15 +++++++++++++++ 4 files changed, 15 insertions(+) rename exercises/{12-Map_an_list => 12-Map_and_list}/README.md (100%) rename exercises/{12-Map_an_list => 12-Map_and_list}/app.py (100%) rename exercises/{12-Map_an_list => 12-Map_and_list}/test.py (100%) diff --git a/exercises/12-Map_an_list/README.md b/exercises/12-Map_and_list/README.md similarity index 100% rename from exercises/12-Map_an_list/README.md rename to exercises/12-Map_and_list/README.md diff --git a/exercises/12-Map_an_list/app.py b/exercises/12-Map_and_list/app.py similarity index 100% rename from exercises/12-Map_an_list/app.py rename to exercises/12-Map_and_list/app.py diff --git a/exercises/12-Map_an_list/test.py b/exercises/12-Map_and_list/test.py similarity index 100% rename from exercises/12-Map_an_list/test.py rename to exercises/12-Map_and_list/test.py diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index e69de29b..dd34fd0f 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -0,0 +1,15 @@ +theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1] + +def other(numbers): + if numbers == 1: + return "wiki" + else: + return "woko" +result = list(map(other, theBools)) +print(result) + + + +rate = lambda x : "wiki" if (x == 1) else "woko" +sample = list(map(rate, theBools)) +print(sample) From 855fc0d8b5b3e7c145297c4d79b935d7667974eb Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 22:34:54 +0000 Subject: [PATCH 69/92] 13.2 exercises --- exercises/12.4-Map_list_of_objects/app.py | 15 --------------- exercises/12.5-Yes_and_no/app.py | 15 +++++++++++++++ exercises/13.2-filter_done_tasks/app.py | 23 +++++++++++++++++++++++ 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index dd34fd0f..e69de29b 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -1,15 +0,0 @@ -theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1] - -def other(numbers): - if numbers == 1: - return "wiki" - else: - return "woko" -result = list(map(other, theBools)) -print(result) - - - -rate = lambda x : "wiki" if (x == 1) else "woko" -sample = list(map(rate, theBools)) -print(sample) diff --git a/exercises/12.5-Yes_and_no/app.py b/exercises/12.5-Yes_and_no/app.py index e69de29b..dd34fd0f 100644 --- a/exercises/12.5-Yes_and_no/app.py +++ b/exercises/12.5-Yes_and_no/app.py @@ -0,0 +1,15 @@ +theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1] + +def other(numbers): + if numbers == 1: + return "wiki" + else: + return "woko" +result = list(map(other, theBools)) +print(result) + + + +rate = lambda x : "wiki" if (x == 1) else "woko" +sample = list(map(rate, theBools)) +print(sample) diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py index e69de29b..8a8b2798 100644 --- a/exercises/13.2-filter_done_tasks/app.py +++ b/exercises/13.2-filter_done_tasks/app.py @@ -0,0 +1,23 @@ +tasks = [ + { "label": 'Eat my lunch', "done": True }, + { "label": 'Make the bed', "done": False }, + { "label": 'Have some fun', "done": False }, + { "label": 'Finish the replits', "done": False }, + { "label": 'Replit the finishes', "done": True }, + { "label": 'Ask for a raise', "done": False }, + { "label": 'Read a book', "done": True }, + { "label": 'Make a trip', "done": False } +] + + + + +#using function +def my_function(items): + return items['done'] +result = list(filter(my_function, tasks)) +print(result) + +#lambda expretion +done_tasks = list(filter(lambda x: x['done'], tasks)) +print(done_tasks) \ No newline at end of file From ef1b92f8500d32353a703c83f1341ebb9a110459 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 23:23:24 +0000 Subject: [PATCH 70/92] readme --- exercises/12.6-Transformers/app.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py index 42700aa8..de3a887e 100644 --- a/exercises/12.6-Transformers/app.py +++ b/exercises/12.6-Transformers/app.py @@ -15,5 +15,4 @@ def my_function(items): return items['name'] +' '+items['lastName'] result = list(map(my_function, incomingAJAXData)) -sample = set(result) -print(sample) +print(result) From 9f991e3f756936d4b706eab4221778836ef41eb1 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 23:25:16 +0000 Subject: [PATCH 71/92] readme --- exercises/13.3-Filter_list_strings/app.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index 60dd52fe..d947ea5c 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -8,11 +8,10 @@ def filteringList(word): else: return False -result = filter(filteringList, names) -my_names = set(result) +my_names = list(filter(filteringList, names)) print(my_names) -result = [s for s in names if 'am' in s] -print(result) \ No newline at end of file +my_names = [s for s in names if 'am' in s] +print(my_names) \ No newline at end of file From a07a1a5e90655334d961413976890a1e594da5b4 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 23:34:08 +0000 Subject: [PATCH 72/92] readme --- exercises/14-Matrix_Builder/README.md | 19 +++++++++++++++++++ exercises/14-Matrix_Builder/app.py | 0 exercises/14-Matrix_Builder/test.py | 0 3 files changed, 19 insertions(+) create mode 100644 exercises/14-Matrix_Builder/README.md create mode 100644 exercises/14-Matrix_Builder/app.py create mode 100644 exercises/14-Matrix_Builder/test.py diff --git a/exercises/14-Matrix_Builder/README.md b/exercises/14-Matrix_Builder/README.md new file mode 100644 index 00000000..138e508c --- /dev/null +++ b/exercises/14-Matrix_Builder/README.md @@ -0,0 +1,19 @@ +# `14` Matrix Builder + +After some malicious code, mainly by Mr. Smith, the matrix has some gaping +hole and it needs some help to rebuild. Create a matrix of random 0's, and 1's based on a parameter. + +#📝Instructions +1. Create a function called matrixBuilder, which will expect 1 parameter (an integer). + This number represents the amount of rows and columns for the matrix. + Example: 5 means that the matrix should be 5x5. +2. This function should return a list of lists that represents the matrix. Example: 3 should return: + +[ + [0, 1, 1], + [1, 0, 1], + [0, 0, 0] +] + +💡Hint: +Remember that the 1's and 0's are random. \ No newline at end of file diff --git a/exercises/14-Matrix_Builder/app.py b/exercises/14-Matrix_Builder/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/14-Matrix_Builder/test.py b/exercises/14-Matrix_Builder/test.py new file mode 100644 index 00000000..e69de29b From 811d6e99232efbb9ebf7b994584cfd15771522aa Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 23:51:21 +0000 Subject: [PATCH 73/92] functions random numbers --- exercises/12.4-Map_list_of_objects/app.py | 9 +++++++++ exercises/14-Matrix_Builder/app.py | 13 +++++++++++++ 2 files changed, 22 insertions(+) diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index e69de29b..0818be4c 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -0,0 +1,9 @@ +people = [ + { "name": 'Joe', "birthDate": (1986,10,24) }, + { "name": 'Bob', "birthDate": (1975,5,24) }, + { "name": 'Erika', "birthDate": (1989,6,12) }, + { "name": 'Dylan', "birthDate": (1999,12,14) }, + { "name": 'Steve', "birthDate": (2003,4,24) } +] + + diff --git a/exercises/14-Matrix_Builder/app.py b/exercises/14-Matrix_Builder/app.py index e69de29b..f524f573 100644 --- a/exercises/14-Matrix_Builder/app.py +++ b/exercises/14-Matrix_Builder/app.py @@ -0,0 +1,13 @@ +import random + +def matrix_function(numbers): + row = [] + columns = [] + for i in range(numbers): + i+=i + for x in range(numbers): + x+=i + columns.append(random.randint(0,1)*1) + row.append(columns) + return row +print(matrix_function(5)) \ No newline at end of file From ad60a2de1b9c9717472578f75adfd9b9278cef71 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 11 Sep 2019 23:56:08 +0000 Subject: [PATCH 74/92] readme --- exercises/12.4-Map_list_of_objects/app.py | 14 ++++++++++++++ exercises/14-Matrix_Builder/README.md | 3 ++- exercises/14-Matrix_Builder/app.py | 5 ++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index 0818be4c..b5f8bcbe 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -7,3 +7,17 @@ ] +from datetime import date +def calculateAge(birthDate): + today = date.today() + age = today.year - birthDate.year - ((today.month, today.day) < (birthDate.month, birthDate.day)) + return age + +name_list = list(map(lambda x: "Hello my name is " + str(x["name"]) + " and I am " + calculateAge(date(int(x["birthDate"]))) + " years old", people)) + + +print(str(name_list)) + + +#revisar esto +#esta devolviendo los names y un solo parametro the los años \ No newline at end of file diff --git a/exercises/14-Matrix_Builder/README.md b/exercises/14-Matrix_Builder/README.md index 138e508c..fe2248f8 100644 --- a/exercises/14-Matrix_Builder/README.md +++ b/exercises/14-Matrix_Builder/README.md @@ -8,12 +8,13 @@ hole and it needs some help to rebuild. Create a matrix of random 0's, and 1's b This number represents the amount of rows and columns for the matrix. Example: 5 means that the matrix should be 5x5. 2. This function should return a list of lists that represents the matrix. Example: 3 should return: - +```py [ [0, 1, 1], [1, 0, 1], [0, 0, 0] ] +``` 💡Hint: Remember that the 1's and 0's are random. \ No newline at end of file diff --git a/exercises/14-Matrix_Builder/app.py b/exercises/14-Matrix_Builder/app.py index f524f573..ae72b8ce 100644 --- a/exercises/14-Matrix_Builder/app.py +++ b/exercises/14-Matrix_Builder/app.py @@ -10,4 +10,7 @@ def matrix_function(numbers): columns.append(random.randint(0,1)*1) row.append(columns) return row -print(matrix_function(5)) \ No newline at end of file +print(matrix_function(5)) + +#this in onle returning the 5 integer numbers +# have to reviewing this \ No newline at end of file From 3775b9a5b8c3e06903cb57a0df2b16da67a4dfb0 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 12 Sep 2019 00:21:48 +0000 Subject: [PATCH 75/92] readme --- .../RAEDME.md | 8 ++++++ .../app.py | 0 .../test.py | 0 exercises/14.1-Parking_lot_check/README.md | 25 +++++++++++++++++++ exercises/14.1-Parking_lot_check/app.py | 0 exercises/14.1-Parking_lot_check/test.py | 0 6 files changed, 33 insertions(+) create mode 100644 exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md create mode 100644 exercises/13.4-Making_HTML_with_filter_and_map/app.py create mode 100644 exercises/13.4-Making_HTML_with_filter_and_map/test.py create mode 100644 exercises/14.1-Parking_lot_check/README.md create mode 100644 exercises/14.1-Parking_lot_check/app.py create mode 100644 exercises/14.1-Parking_lot_check/test.py diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md b/exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md new file mode 100644 index 00000000..b658026c --- /dev/null +++ b/exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md @@ -0,0 +1,8 @@ +#`13.4` Making HTML using filter function and map funtion + +#📝Instructions from your teacher: +1. Fill the generateLI and filterColors function to make the exercise print the following HTML with only the sexy colors: +```py +Expexted: +
  • Red
  • Orange
  • Pink
  • Violet
+``` \ No newline at end of file diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/app.py b/exercises/13.4-Making_HTML_with_filter_and_map/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/test.py b/exercises/13.4-Making_HTML_with_filter_and_map/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/14.1-Parking_lot_check/README.md b/exercises/14.1-Parking_lot_check/README.md new file mode 100644 index 00000000..38e0159e --- /dev/null +++ b/exercises/14.1-Parking_lot_check/README.md @@ -0,0 +1,25 @@ +#`14.1` Parking Lot + +We can use a 2 dimensional array (matrix) to represent the current state of a parking lot like this: +![Parking lot](https://storage.googleapis.com/replit/images/1558366147943_71c41e2a3f01564b5bdba6618797af79.pn) +```py +parking_state = [ + [1,0,1,1,0,1], + [2,0,1,1,0,1], + [1,0,2,1,0,1], + [1,0,1,1,0,1], + [1,0,1,1,0,2], + [1,0,1,1,0,1], +] +``` + +# 📝Instructions +1. Create a function getParkingLotState() that returns an object with totalSlots, availableSlots and occupiedSlots like the following: +const state = { + totalSlots: 12, + availableSlots: 3, + occupiedSlots: 9 +} + +💡Hints +You have to do a nested loop diff --git a/exercises/14.1-Parking_lot_check/app.py b/exercises/14.1-Parking_lot_check/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py new file mode 100644 index 00000000..e69de29b From 98c41027ddfbdd2c3bff90d5af17789db10c2ed8 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 12 Sep 2019 22:27:15 +0000 Subject: [PATCH 76/92] matrix builder --- exercises/14-Matrix_Builder/app.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/exercises/14-Matrix_Builder/app.py b/exercises/14-Matrix_Builder/app.py index ae72b8ce..58f06fc3 100644 --- a/exercises/14-Matrix_Builder/app.py +++ b/exercises/14-Matrix_Builder/app.py @@ -2,15 +2,15 @@ def matrix_function(numbers): row = [] - columns = [] for i in range(numbers): i+=i + columns = [] for x in range(numbers): x+=i columns.append(random.randint(0,1)*1) row.append(columns) - return row + return row print(matrix_function(5)) -#this in onle returning the 5 integer numbers +#this in onle returning the 5 integer numbers into the rows and columns # have to reviewing this \ No newline at end of file From b47aabecfcdd8281b38b3273315ebd0d985168f6 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 12 Sep 2019 22:31:17 +0000 Subject: [PATCH 77/92] readme --- exercises/15-Techno_beat/README.md | 27 +++++++++++++++++++++++++++ exercises/15-Techno_beat/app.py | 0 exercises/15-Techno_beat/test.py | 0 3 files changed, 27 insertions(+) create mode 100644 exercises/15-Techno_beat/README.md create mode 100644 exercises/15-Techno_beat/app.py create mode 100644 exercises/15-Techno_beat/test.py diff --git a/exercises/15-Techno_beat/README.md b/exercises/15-Techno_beat/README.md new file mode 100644 index 00000000..6907c0bd --- /dev/null +++ b/exercises/15-Techno_beat/README.md @@ -0,0 +1,27 @@ +#`15` Techno Beats +You are working with a DJ and he needs a program that can create a beats for his songs. + +#📝Instructions: +1. Create a function lyricsGenerator that receives a list + The list passed to the function will be something like this: + [0,0,1,1,0,0,0] +2. For each Zero you will add to the string 'Boom' +3. For each One you will add to the string 'Drop the base' + +Constraints +If you find the number One (1) three times in a row, should ALSO ADD to the string "!!!Break the base!!!" + +```py +Expected Function Output: +A string which should be comprise of Boom or Drop the base or !!!Break the base!!! +Excepted Output: +Boom Boom Drop the base Drop the base Boom Boom Boom +Boom Boom Drop the base Drop the base Drop the base !!!Break the base!!! Boom Boom Boom +Boom Boom Boom +Drop the base Boom Drop the base +Drop the base Drop the base Drop the base !!!Break the base!!! +``` + + +💡Hints +Remember to use helper variables \ No newline at end of file diff --git a/exercises/15-Techno_beat/app.py b/exercises/15-Techno_beat/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/15-Techno_beat/test.py b/exercises/15-Techno_beat/test.py new file mode 100644 index 00000000..e69de29b From e7f594c0b560579f74f37e93a74c4894639c18ab Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 12 Sep 2019 23:26:57 +0000 Subject: [PATCH 78/92] test loop list --- exercises/01.3-Print-the-last-one/README.md | 6 +++- exercises/01.3-Print-the-last-one/test.py | 2 +- exercises/01.4-Add-item-to-list/README.md | 6 ++-- exercises/01.4-Add-item-to-list/app.py | 5 ++- exercises/01.4-Add-item-to-list/test.py | 2 +- exercises/01.5-loop-seventeen/app.py | 4 +-- exercises/02-Loop-list/README.md | 33 ------------------- exercises/02-Loop-list/app.py | 4 +-- exercises/02-Loop-list/test.py | 10 +++++- .../README.md | 0 .../app.py | 0 .../test.py | 0 12 files changed, 25 insertions(+), 47 deletions(-) rename exercises/{12.1_more_mapping => 12.1-more_mapping}/README.md (100%) rename exercises/{12.1_more_mapping => 12.1-more_mapping}/app.py (100%) rename exercises/{12.1_more_mapping => 12.1-more_mapping}/test.py (100%) diff --git a/exercises/01.3-Print-the-last-one/README.md b/exercises/01.3-Print-the-last-one/README.md index 618d2ee3..1d38c7cf 100644 --- a/exercises/01.3-Print-the-last-one/README.md +++ b/exercises/01.3-Print-the-last-one/README.md @@ -13,5 +13,9 @@ returns the `length of` name_list . 1. Create a variable named the_last_one, and assign it the LAST element of my_stupid_list. 2. Then, print it on the console. + 💡Hint: -`Remember import random function` \ No newline at end of file +```py +-Remember import random function +-Ask to Google How import random in python? +``` \ No newline at end of file diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index e52f7739..89f8ab19 100644 --- a/exercises/01.3-Print-the-last-one/test.py +++ b/exercises/01.3-Print-the-last-one/test.py @@ -15,4 +15,4 @@ def test_create_assign(): @pytest.mark.it("print in the console the_last_one") def test_output(): captured = buffer.getvalue() - assert print(app.the_last_one) in captured + assert str(app.the_last_one) in captured diff --git a/exercises/01.4-Add-item-to-list/README.md b/exercises/01.4-Add-item-to-list/README.md index 1c279e95..997888e1 100644 --- a/exercises/01.4-Add-item-to-list/README.md +++ b/exercises/01.4-Add-item-to-list/README.md @@ -5,9 +5,9 @@ 💡Tips: -1. You have to `import random` function -2. Use the `random()` function to get random numbers. -3. Search on Google how to use random function. +You have to `import random` function. +Use the `random()` function to get random numbers. +Search on Google how to use random function. Expected in the console something similar like this: diff --git a/exercises/01.4-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py index 499b8830..a31b9eac 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -5,7 +5,6 @@ #The magic is here: for num in range(1, 11): - my_list.append(random.randint(1, 10)) + my_list.append(random.randint(1, 100)) - -print(my_list) \ No newline at end of file +print(my_list) diff --git a/exercises/01.4-Add-item-to-list/test.py b/exercises/01.4-Add-item-to-list/test.py index 70084e63..d253d0ad 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -9,7 +9,7 @@ @pytest.mark.it("Add ten random numbers to the list") def test_add_numb(): - assert app.my_list.append(random.randint(1, 10)) + assert app.my_list.append(random.randint(1, 100)) is not None @pytest.mark.it("Output of the list with 15 items numbers") def test_output(): diff --git a/exercises/01.5-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py index ec89829b..7dc2e8e7 100644 --- a/exercises/01.5-loop-seventeen/app.py +++ b/exercises/01.5-loop-seventeen/app.py @@ -1,3 +1,3 @@ #Your code here, have fun: - - +for numb in range(1,18): + print(numb) \ No newline at end of file diff --git a/exercises/02-Loop-list/README.md b/exercises/02-Loop-list/README.md index 839ab8f9..b3d6de33 100644 --- a/exercises/02-Loop-list/README.md +++ b/exercises/02-Loop-list/README.md @@ -35,37 +35,4 @@ Expected console result: 34 3 55 -33 -435 -4 -6 -54 -63 -45 -4 -67 -56 -47 -1 -34 -54 -32 -54 -1 -78 -98 -0 -9 -8 -98 -76 -7 -54 -2 -3 -42 -456 -4 -3321 -5 ``` \ No newline at end of file diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index 5805d932..5d7798c7 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -2,8 +2,8 @@ #You don't to change nothing above, your code go below: -for x in my_list: - print(x) +for numbers in my_list: + print(numbers) diff --git a/exercises/02-Loop-list/test.py b/exercises/02-Loop-list/test.py index c12bb291..66a42606 100644 --- a/exercises/02-Loop-list/test.py +++ b/exercises/02-Loop-list/test.py @@ -6,9 +6,17 @@ import pytest import app +import os @pytest.mark.it("Print the all items from the list") def test_output(): captured = buffer.getvalue() - assert "232\n32\n14\n55\n4\n3\n32\n3\n24\n5\n5\n5\n34\n2\n35\n5365743\n52\n34\n3\n55\n" in captured + assert "232\n32\n1\n4\n55\n4\n3\n32\n3\n24\n5\n5\n5\n34\n2\n35\n5365743\n52\n34\n3\n55\n" in captured +@pytest.mark.it("Be sure that you use the for loop in the exercises") +def test_use_forLoop(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for ") > 0 \ No newline at end of file diff --git a/exercises/12.1_more_mapping/README.md b/exercises/12.1-more_mapping/README.md similarity index 100% rename from exercises/12.1_more_mapping/README.md rename to exercises/12.1-more_mapping/README.md diff --git a/exercises/12.1_more_mapping/app.py b/exercises/12.1-more_mapping/app.py similarity index 100% rename from exercises/12.1_more_mapping/app.py rename to exercises/12.1-more_mapping/app.py diff --git a/exercises/12.1_more_mapping/test.py b/exercises/12.1-more_mapping/test.py similarity index 100% rename from exercises/12.1_more_mapping/test.py rename to exercises/12.1-more_mapping/test.py From 5e18f8c95a8b92e6c92ed2038f819acfc63253c0 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 13 Sep 2019 00:15:37 +0000 Subject: [PATCH 79/92] pytest 02.4 --- exercises/02-Loop-list/app.py | 8 +++---- exercises/02.1-Loop-from-the-top/README.md | 2 +- exercises/02.1-Loop-from-the-top/test.py | 9 ++++++++ exercises/02.2-Loop-adding-two/README.md | 2 +- exercises/02.2-Loop-adding-two/app.py | 1 - exercises/02.2-Loop-adding-two/test.py | 10 +++++++++ .../README.md | 21 +++++++++++++----- .../02.3-loop-from-the-half-to-the-end/app.py | 6 ++--- .../test.py | 22 ++++++++++++++++++- exercises/02.4-One_last_looping/README.md | 10 +++++---- 10 files changed, 71 insertions(+), 20 deletions(-) diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index 5d7798c7..d06155f9 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,13 +1,13 @@ -my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,3,5,5365743,52,34,3,55] +my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,35,5365743,52,34,3,55] #You don't to change nothing above, your code go below: -for numbers in my_list: - print(numbers) - +for numbers in my_list: + print(my_list) +#another for #for index in range(len(my_list)): # print(my_list[index]) \ No newline at end of file diff --git a/exercises/02.1-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md index 8688e965..42bca118 100644 --- a/exercises/02.1-Loop-from-the-top/README.md +++ b/exercises/02.1-Loop-from-the-top/README.md @@ -1,4 +1,4 @@ -# `02.1` Instructions from your teacher: +# `02.1` Loop from the top ```js This loop is `looping` the list from beginning to end... increasing one by one. ``` diff --git a/exercises/02.1-Loop-from-the-top/test.py b/exercises/02.1-Loop-from-the-top/test.py index a3d2b435..adf93e4f 100644 --- a/exercises/02.1-Loop-from-the-top/test.py +++ b/exercises/02.1-Loop-from-the-top/test.py @@ -5,8 +5,17 @@ from app import my_sample_list import pytest import app +import os @pytest.mark.it("loop from the last") def test_output(): captured = buffer.getvalue() assert "12\n25\n23\n55\n56432\n48\n23\n867543\n8\n654\n47889\n4\n5\n3423\n" in captured + +@pytest.mark.it("Be sure that use the for loop") +def test_use_for(): + captures = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for ") > 0 diff --git a/exercises/02.2-Loop-adding-two/README.md b/exercises/02.2-Loop-adding-two/README.md index b8f54732..2aec301b 100644 --- a/exercises/02.2-Loop-adding-two/README.md +++ b/exercises/02.2-Loop-adding-two/README.md @@ -1,4 +1,4 @@ -# `10` Loop adding two +# `02.2` Loop adding two ```py This code is `looping` the whole array, `one by one`. diff --git a/exercises/02.2-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py index 72efc9e9..819e4476 100644 --- a/exercises/02.2-Loop-adding-two/app.py +++ b/exercises/02.2-Loop-adding-two/app.py @@ -9,4 +9,3 @@ # # for i in my_sample_list[0::2]: # # print(i) -# print(my_sample_list[::2]) \ No newline at end of file diff --git a/exercises/02.2-Loop-adding-two/test.py b/exercises/02.2-Loop-adding-two/test.py index 195a6c6c..9a4b8f78 100644 --- a/exercises/02.2-Loop-adding-two/test.py +++ b/exercises/02.2-Loop-adding-two/test.py @@ -5,9 +5,19 @@ from app import my_sample_list import pytest import app +import os @pytest.mark.it("Loop two by two") def test_output(): captured = buffer.getvalue() assert "3423\n4\n654\n867543\n48\n55\n25\n" in captured + +@pytest.mark.it("The for loop was used") +def test_use_for(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + diff --git a/exercises/02.3-loop-from-the-half-to-the-end/README.md b/exercises/02.3-loop-from-the-half-to-the-end/README.md index 46ff0af3..727e3bea 100644 --- a/exercises/02.3-loop-from-the-half-to-the-end/README.md +++ b/exercises/02.3-loop-from-the-half-to-the-end/README.md @@ -1,10 +1,21 @@ -# `11` Instructions from your teacher: +# `02.3` Loop from the half to the end + This loop is not looping at all... because the variables initialValue, stopValue and increasingValue are equal to zero. -Instructions -Change the value of those variables to make the loop print only the last half of the array. -Change nothing but the value of those 3 variables! +# 📝Instructions +1. Change the value of those variables to make the loop print only the last half of the list. +2. Change nothing but the value of those 3 variables! + +The result should be something like: -The result should be something like: \ No newline at end of file +```py +23 +48 +56432 +55 +23 +25 +12 +``` \ No newline at end of file diff --git a/exercises/02.3-loop-from-the-half-to-the-end/app.py b/exercises/02.3-loop-from-the-half-to-the-end/app.py index 9dd8c0fc..f5ffd1d4 100644 --- a/exercises/02.3-loop-from-the-half-to-the-end/app.py +++ b/exercises/02.3-loop-from-the-half-to-the-end/app.py @@ -1,9 +1,9 @@ my_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] #Your code here: -inicialValue = 0 -stopValue = 0 -increaseValue = 0 +inicialValue = 7 +stopValue = 14 +increaseValue = 1 for i in range(inicialValue, stopValue): if i == my_list[i]: diff --git a/exercises/02.3-loop-from-the-half-to-the-end/test.py b/exercises/02.3-loop-from-the-half-to-the-end/test.py index 0aba17d1..7d453319 100644 --- a/exercises/02.3-loop-from-the-half-to-the-end/test.py +++ b/exercises/02.3-loop-from-the-half-to-the-end/test.py @@ -1 +1,21 @@ -import os \ No newline at end of file +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Loop from the half to the end") +def test_half_to_end(): + captured = buffer.getvalue() + assert "23\n48\n56432\n55\n23\n25\n12\n" in captured + +@pytest.mark.it("The for loop was used") +def test_use_for(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 \ No newline at end of file diff --git a/exercises/02.4-One_last_looping/README.md b/exercises/02.4-One_last_looping/README.md index c4eff82c..c103c829 100644 --- a/exercises/02.4-One_last_looping/README.md +++ b/exercises/02.4-One_last_looping/README.md @@ -1,14 +1,16 @@ -#`12` Instructions from your teacher: +#`02.4` One last looping + +#📝Instructions: 1. Change the second item value to 'Steven' 2. Set the last position to 'Pepe' 3. Set the first element to the value of the 3rd element concatenated to the value of the 5th element. -4. Reverse loop (from the end to the beginning) the whole array and print all the elements. +4. Reverse loop (from the end to the beginning) the whole list and print all the elements. 💡HINT: -1. Remember that list start at position 0. +-Remember that list start at position 0. The result should be something like this: -```js +```py Pepe Bart Cesco From 63e7c302e8092fc6065e4c9d1019491e2cc28511 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 13 Sep 2019 00:58:33 +0000 Subject: [PATCH 80/92] pytest 2.4 --- exercises/02.4-One_last_looping/app.py | 16 ++++++---------- exercises/02.4-One_last_looping/test.py | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index 23f797a7..46ec7b65 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -2,16 +2,12 @@ #Your code here: -my_sample_list[1] == "Steve" -my_sample_list[-1] == "Pepe" -my_sample_list[0] == my_sample_list[2] + my_sample_list[4] - - -for i in reversed(my_sample_list): - print(i) +my_sample_list[1] = "Steve" +my_sample_list[-1] = "Pepe" +my_sample_list[0] = my_sample_list[2] + my_sample_list[4] new_list = [] -for i in range(len(my_sample_list)): - new_list.append(my_sample_list[-i-1]) -print(new_list) \ No newline at end of file +for names in range(len(my_sample_list)): + new_list.append(my_sample_list[-names-1]) +print('\n'.join(new_list)) diff --git a/exercises/02.4-One_last_looping/test.py b/exercises/02.4-One_last_looping/test.py index e69de29b..3006fd91 100644 --- a/exercises/02.4-One_last_looping/test.py +++ b/exercises/02.4-One_last_looping/test.py @@ -0,0 +1,21 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Add, change values and reversed list") +def test_output(): + captured = buffer.getvalue() + assert "Pepe\nBart\nCesco\nFernando\nLou\nMaria\nPedro\nLebron\nRuth\nSteve\nRuthPedro\n" in captured + +@pytest.mark.it("The for lopp was good") +def test_use_foor(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 \ No newline at end of file From 69d05655b4e8fd5def42d192c156c1c86e95cd71 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 13 Sep 2019 03:41:46 +0000 Subject: [PATCH 81/92] test flip list --- exercises/02.4-One_last_looping/app.py | 11 ++++--- exercises/02.5-Finding_wally/README.md | 4 ++- exercises/02.5-Finding_wally/app.py | 13 ++------- exercises/02.5-Finding_wally/test.py | 22 ++++++++++++++ .../{RAEDME.md => README.md} | 6 ++-- exercises/02.6-letter_counter/app.py | 6 ---- exercises/02.6-letter_counter/test.py | 12 ++++++++ exercises/03-flip_list/README.md | 5 ++-- exercises/03-flip_list/app.py | 9 +++--- exercises/03-flip_list/test.py | 29 +++++++++++++++++++ 10 files changed, 86 insertions(+), 31 deletions(-) rename exercises/02.6-letter_counter/{RAEDME.md => README.md} (88%) diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index 46ec7b65..e6afa2fe 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -7,7 +7,10 @@ my_sample_list[0] = my_sample_list[2] + my_sample_list[4] -new_list = [] -for names in range(len(my_sample_list)): - new_list.append(my_sample_list[-names-1]) -print('\n'.join(new_list)) +# new_list = [] +# for names in range(len(my_sample_list)): +# new_list.append(my_sample_list[-names-1]) +# print('\n'.join(new_list)) + +for person in range(len(my_sample_list)): + print(my_sample_list[-person-1]) \ No newline at end of file diff --git a/exercises/02.5-Finding_wally/README.md b/exercises/02.5-Finding_wally/README.md index 0be4fffd..ecc7cfb4 100644 --- a/exercises/02.5-Finding_wally/README.md +++ b/exercises/02.5-Finding_wally/README.md @@ -1,4 +1,6 @@ -# `13` Instructions from your teacher: +# `02.5` Finding Wally + +#📝Instructions: 1. Find Wally :) 2. Print the position(s) of Wally in the console. diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index a37837a3..fab02072 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -2,13 +2,6 @@ #Your code here: -position = [] -for i in range(0, len(people)): - if people[i] == "Wally": - position.append(i) -print(position) - -#i thing is the second one -for i in range(len(people)): - if people[i] == "Wally": - print(i) \ No newline at end of file +for person in range(len(people)): + if people[person] == "Wally": + print(person) diff --git a/exercises/02.5-Finding_wally/test.py b/exercises/02.5-Finding_wally/test.py index e69de29b..524815dc 100644 --- a/exercises/02.5-Finding_wally/test.py +++ b/exercises/02.5-Finding_wally/test.py @@ -0,0 +1,22 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Find and print the position of Wally") +def test_find(): + captured = buffer.getvalue() + assert "65\n198\n" in captured + + +@pytest.mark.it("Use for loop") +def test_for_loop(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 diff --git a/exercises/02.6-letter_counter/RAEDME.md b/exercises/02.6-letter_counter/README.md similarity index 88% rename from exercises/02.6-letter_counter/RAEDME.md rename to exercises/02.6-letter_counter/README.md index 14969db6..c0e0e327 100644 --- a/exercises/02.6-letter_counter/RAEDME.md +++ b/exercises/02.6-letter_counter/README.md @@ -1,12 +1,12 @@ -# `14` Instructions from your teacher: +# `02.6` Letter counter -```js +```py Letter Counter Our customer needs a program that counts the letters repetitions in a given string, I know that's weird, but they are very adamant, We need this asap! ``` -📝Instructions: +#📝Instructions: 1. letters and the values are the number of times it is repeated throughout the string. Example diff --git a/exercises/02.6-letter_counter/app.py b/exercises/02.6-letter_counter/app.py index ad637919..201664ba 100644 --- a/exercises/02.6-letter_counter/app.py +++ b/exercises/02.6-letter_counter/app.py @@ -10,9 +10,3 @@ count[i] = 1 print(count) - -letter = {} -for i in par: - letter = letter.get(i, 0) + 1 - -print(letter) \ No newline at end of file diff --git a/exercises/02.6-letter_counter/test.py b/exercises/02.6-letter_counter/test.py index e69de29b..efc3d01d 100644 --- a/exercises/02.6-letter_counter/test.py +++ b/exercises/02.6-letter_counter/test.py @@ -0,0 +1,12 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it() + + +@pytest.mark.it() \ No newline at end of file diff --git a/exercises/03-flip_list/README.md b/exercises/03-flip_list/README.md index cec0b7f1..82015b5f 100644 --- a/exercises/03-flip_list/README.md +++ b/exercises/03-flip_list/README.md @@ -1,6 +1,7 @@ -# `15` Instructions from your teacher: +# `03` Flip list -Using a loop, invert the "arr" list. +#📝Instructions: +1. Using a loop, invert the "arr" list. ```js Initial list: [45, 67, 87, 23, 5, 32, 60] diff --git a/exercises/03-flip_list/app.py b/exercises/03-flip_list/app.py index 82291217..3179c62f 100644 --- a/exercises/03-flip_list/app.py +++ b/exercises/03-flip_list/app.py @@ -2,9 +2,8 @@ #your code below: -for i in range(len(arr)): - print(arr[-(i+1)]) - -for i in range(len(arr)): - print(arr[-i-1]) \ No newline at end of file +new_list = [] +for numb in range(len(arr)): + new_list.append(arr[-(numb+1)]) +print(new_list) diff --git a/exercises/03-flip_list/test.py b/exercises/03-flip_list/test.py index e69de29b..68d84c89 100644 --- a/exercises/03-flip_list/test.py +++ b/exercises/03-flip_list/test.py @@ -0,0 +1,29 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Flip entire list") +def test_flip(): + captured = buffer.getvalue() + + assert "[60, 32, 5, 23, 87, 67, 45]" in captured + + +#test this +@pytest.mark.it("Create new variable") +def test_new_list(): + assert new_list == new_list + + +@pytest.mark.it("Use for loop for flip list") +def test_loop(): + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 \ No newline at end of file From f0f388719ef01a6442496e4ae6669ae5f620b38b Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 13 Sep 2019 22:05:44 +0000 Subject: [PATCH 82/92] mixed list --- exercises/03-flip_list/README.md | 5 ++++- exercises/03-flip_list/test.py | 6 +++++- exercises/04-mixed_list/README.md | 28 ++++++++++++++++------------ exercises/04-mixed_list/app.py | 17 ++++++++++------- exercises/04-mixed_list/test.py | 25 +++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 21 deletions(-) diff --git a/exercises/03-flip_list/README.md b/exercises/03-flip_list/README.md index 82015b5f..bd6003ce 100644 --- a/exercises/03-flip_list/README.md +++ b/exercises/03-flip_list/README.md @@ -1,7 +1,10 @@ # `03` Flip list #📝Instructions: -1. Using a loop, invert the "arr" list. +1. Create a variable new_list +2. Using a loop, invert the "arr" list. +3. Append the result loop into the new_list variable . +4. With print() function output in the console the result that you have. ```js Initial list: [45, 67, 87, 23, 5, 32, 60] diff --git a/exercises/03-flip_list/test.py b/exercises/03-flip_list/test.py index 68d84c89..467123f0 100644 --- a/exercises/03-flip_list/test.py +++ b/exercises/03-flip_list/test.py @@ -17,7 +17,11 @@ def test_flip(): #test this @pytest.mark.it("Create new variable") def test_new_list(): - assert new_list == new_list + captured = buffer.getvalue() + + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("new_list") > 0 @pytest.mark.it("Use for loop for flip list") diff --git a/exercises/04-mixed_list/README.md b/exercises/04-mixed_list/README.md index 8c64f391..6ade569c 100644 --- a/exercises/04-mixed_list/README.md +++ b/exercises/04-mixed_list/README.md @@ -1,19 +1,23 @@ -# `16` Instructions from your teacher: +# `04` Mixed List +#📝instructions: 1. Write a function to programmatically print in the console the -types of the values that the list contains in each position. +types of the values that the list contains in each position +2. You can use the for loop. -```js +```py The console must have something like this: -``` -number -boolean -string -object -string -number -object + + + + + + + + +``` 💡Hint: -You can use the type() python function. \ No newline at end of file +You can use the type() python function. +Remember that len() return the large of your list. \ No newline at end of file diff --git a/exercises/04-mixed_list/app.py b/exercises/04-mixed_list/app.py index ece2db7a..1ff9370d 100644 --- a/exercises/04-mixed_list/app.py +++ b/exercises/04-mixed_list/app.py @@ -2,12 +2,15 @@ # Your code below: -for i in range(len(mix)): - if mix[i] == i: - i += 1 - print(type(mix[i])) +# for i in range(len(mix)): +# if mix[i] == i: +# i += 1 +# print(type(mix[i])) +# items = [] +# for i in range(len(mix)): +# items = mix[i] +# print(type(items)) -for i in range(len(mix)): - item = mix[i] - print(type(item)) \ No newline at end of file +for items in range(len(mix)): + print(type(mix[items])) \ No newline at end of file diff --git a/exercises/04-mixed_list/test.py b/exercises/04-mixed_list/test.py index e69de29b..baf7948a 100644 --- a/exercises/04-mixed_list/test.py +++ b/exercises/04-mixed_list/test.py @@ -0,0 +1,25 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Print the types of items from list") +def test_type_items(): + captured = buffer.getvalue() + assert "\n\n\n\n\n\n\n" in captured + + +@pytest.mark.it("Use for loop") +def test_use_for_loop(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for")>0 + +@pytest.mark.it("Use len() function") +def test_use_len(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("len()")>0 \ No newline at end of file From 648c07458c49d28991a7aa8d2fe2ac58312d397e Mon Sep 17 00:00:00 2001 From: ESPINO Date: Fri, 13 Sep 2019 22:11:01 +0000 Subject: [PATCH 83/92] pytest mixed list --- exercises/04-mixed_list/app.py | 5 ++++- exercises/04-mixed_list/test.py | 8 +++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/exercises/04-mixed_list/app.py b/exercises/04-mixed_list/app.py index 1ff9370d..35ebe33f 100644 --- a/exercises/04-mixed_list/app.py +++ b/exercises/04-mixed_list/app.py @@ -13,4 +13,7 @@ # print(type(items)) for items in range(len(mix)): - print(type(mix[items])) \ No newline at end of file + print(type(mix[items])) + + + #ver lo del metodo de test type and len functions \ No newline at end of file diff --git a/exercises/04-mixed_list/test.py b/exercises/04-mixed_list/test.py index baf7948a..c28fa93a 100644 --- a/exercises/04-mixed_list/test.py +++ b/exercises/04-mixed_list/test.py @@ -22,4 +22,10 @@ def test_use_for_loop(): def test_use_len(): f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') content = f.read() - assert content.find("len()")>0 \ No newline at end of file + assert content.find("len")>0 + +@pytest.mark.it("Use type() function") +def test_use_type(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("type")>0 \ No newline at end of file From 09c29c60bcae1f7b2b31cfc6da712658f5a746de Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 01:52:57 +0000 Subject: [PATCH 84/92] 08.2 pytest --- exercises/04.1-count_on/README.md | 5 ++-- exercises/05-Sum_all_items/README.md | 6 ++-- exercises/05-Sum_all_items/app.py | 13 ++++----- exercises/05-Sum_all_items/test.py | 19 ++++++++++++ exercises/05.1-sum_odd_items/README.md | 19 +++++++----- exercises/05.1-sum_odd_items/test.py | 19 ++++++++++++ exercises/06-forEach_loop/README.md | 18 +++++------- exercises/06-forEach_loop/app.py | 4 +-- exercises/06-forEach_loop/test.py | 24 +++++++++++++++ .../06.1-Everything_is_awesome/README.md | 2 +- exercises/06.1-Everything_is_awesome/app.py | 29 +++++++------------ exercises/06.1-Everything_is_awesome/test.py | 20 +++++++++++++ exercises/07-Dowhile_DO_DO/README.md | 7 +++-- exercises/08-Delete_element/README.md | 6 ++-- exercises/08.1-Merge_list/README.md | 13 +++++++-- exercises/08.1-Merge_list/app.py | 8 ----- exercises/08.1-Merge_list/test.py | 20 +++++++++++++ exercises/08.2-Divide_and_conquer/README.md | 6 ++-- exercises/08.2-Divide_and_conquer/app.py | 20 ++++++------- exercises/08.2-Divide_and_conquer/test.py | 26 +++++++++++++++++ 20 files changed, 203 insertions(+), 81 deletions(-) diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md index 77c657f4..5a8eaac3 100644 --- a/exercises/04.1-count_on/README.md +++ b/exercises/04.1-count_on/README.md @@ -1,5 +1,6 @@ -# `17` Instructions from your teacher: -`Count On` +# `04.1``Count On` + + As you saw in the last exercise your list can be a mix `types of data` we are going to divide and conquer. Would you be so kind to add all the items with data-type object into the hello list? diff --git a/exercises/05-Sum_all_items/README.md b/exercises/05-Sum_all_items/README.md index 4a3105fa..c6a987c2 100644 --- a/exercises/05-Sum_all_items/README.md +++ b/exercises/05-Sum_all_items/README.md @@ -1,8 +1,10 @@ -# `18` Instructions from your teacher: +# `05` Sum all items + +#📝Instructions: 1. Complete the code of the function "sum" so that it returns the sum of all the items in my_sample_list. -```js +```py The result should be 925960 ``` diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 1ba9ba33..49bf62aa 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -6,17 +6,14 @@ def sum_all_values(items): total = 0 #The magic happens here: - # for i in range(len(items)): - # total += items[i] + for i in range(len(items)): + total += items[i] return total print(sum_all_values(my_sample_list)) -def other(items): - total = 0 - for i in items: - total += i - return total -print(other(my_sample_list)) \ No newline at end of file +#can use this too +# for i in items: +# total += i diff --git a/exercises/05-Sum_all_items/test.py b/exercises/05-Sum_all_items/test.py index e69de29b..723a4e77 100644 --- a/exercises/05-Sum_all_items/test.py +++ b/exercises/05-Sum_all_items/test.py @@ -0,0 +1,19 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Print the sum in the console") +def test_sum(): + captured = buffer.getvalue() + assert "925960\n" in captured + + +@pytest.mark.it("Use for loop") +def test_use_loop(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 \ No newline at end of file diff --git a/exercises/05.1-sum_odd_items/README.md b/exercises/05.1-sum_odd_items/README.md index e921985d..ade38b64 100644 --- a/exercises/05.1-sum_odd_items/README.md +++ b/exercises/05.1-sum_odd_items/README.md @@ -1,15 +1,20 @@ -# `19` +# `05.1` Sum the odd numbers + + # 📝Instructions from your teacher: -1. Create a function called sumOdds that sums all the odd numbers in the "arr" -2. list and returns the result. +1. Create a function called sumOdds that sums all the odd numbers in the "arr" variable. +2. Returns and print the result. # To do this exercise consider: -- You have to `loop the list`. + - You will need to `declare an auxiliar variable outside the loop` to keep adding the values. -- On each loop, you have to `ask if the value of the list in that index position is an odd number`. -- If its odd then add the value to the `auxiliar`. +- create a function +- You have to `loop the list`. +- On each loop, you have to ask if the value of the list in that index position is an odd number. +- If its odd then add the value to the `auxiliar variable`. -💡Hint: an auxiliar variable is a regular variable, the only difference is a logical difference; an +💡Hint: +An auxiliar variable is a regular variable, the only difference is a logical difference; an auxiliar variable is like a chosen one, it'll be useful until it completes its purpose (add all the values, make a copy of a value, etc). \ No newline at end of file diff --git a/exercises/05.1-sum_odd_items/test.py b/exercises/05.1-sum_odd_items/test.py index e69de29b..57a32b3d 100644 --- a/exercises/05.1-sum_odd_items/test.py +++ b/exercises/05.1-sum_odd_items/test.py @@ -0,0 +1,19 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Print the odd number") +def test_odd_numbers(): + captured = buffer.getvalue() + assert "251\n" in captured + +@pytest.mark.it("Looping the function") +def test_loop(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 \ No newline at end of file diff --git a/exercises/06-forEach_loop/README.md b/exercises/06-forEach_loop/README.md index 55431a8b..542e45ac 100644 --- a/exercises/06-forEach_loop/README.md +++ b/exercises/06-forEach_loop/README.md @@ -1,18 +1,14 @@ -# `20` -It is possible to traverse an list using the list.forEach function. -You have to specify what to do on each iteration of the loop. -```js -//item will be the value of the specific item. -//index will be the item index. -//arr will be the -my_list.forEach(function(item, index, arr){ +# `06` ForEach loop -}); +```py +It is possible to traverse an list using for loop function. +You have to specify what to do on each iteration of the loop. ``` - # 📝Instructions Right now, the code is printing all the items in the list: - 1. Please change the function code to print only the numbers `divisible by 14`. + 1. Please change the function code to print only + the numbers `divisible by 14`. 💡HINT + `A number X is divisible by 2 if: (X%2===0)` \ No newline at end of file diff --git a/exercises/06-forEach_loop/app.py b/exercises/06-forEach_loop/app.py index caa4a658..41fd8c4f 100644 --- a/exercises/06-forEach_loop/app.py +++ b/exercises/06-forEach_loop/app.py @@ -3,5 +3,5 @@ for numb in my_list: #the magic go here: - - print(numb) \ No newline at end of file + # if numb % 14 == 0: + print(numb) \ No newline at end of file diff --git a/exercises/06-forEach_loop/test.py b/exercises/06-forEach_loop/test.py index e69de29b..33637450 100644 --- a/exercises/06-forEach_loop/test.py +++ b/exercises/06-forEach_loop/test.py @@ -0,0 +1,24 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Print the numbers divisible by 14") +def test_even(): + captured = buffer.getvalue() + assert "434\n56\n56\n56\n" in captured + +@pytest.mark.it("Use for loop") +def test_for_loop(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("for") > 0 + +@pytest.mark.it("Use conditional statement if/elif") +def test_conditional(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("if") > 0 \ No newline at end of file diff --git a/exercises/06.1-Everything_is_awesome/README.md b/exercises/06.1-Everything_is_awesome/README.md index ef8572b7..6aa75c36 100644 --- a/exercises/06.1-Everything_is_awesome/README.md +++ b/exercises/06.1-Everything_is_awesome/README.md @@ -1,4 +1,4 @@ -# `21` +# `06.1` Everything is Awesome # Instructions from your teacher: diff --git a/exercises/06.1-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py index 910482bb..7e24a366 100644 --- a/exercises/06.1-Everything_is_awesome/app.py +++ b/exercises/06.1-Everything_is_awesome/app.py @@ -1,21 +1,12 @@ my_list = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ] -def sample(items): - return_list = [] - for i in items: - #the magic happens here: - - return return_list -print(sample(my_list)) - - -# def sample(items): -# return_list = [] -# for i in items: -# if i == 1: -# return_list.append(i) -# elif i == 0: -# return_list.append("Yahoo") - -# return return_list -# print(sample(my_list)) \ No newline at end of file +def my_function(numbers): + new_list = [] + for numb in numbers: + #The magic go here: + # if numb == 0: + # new_list.append("Yahoo") + # elif numb == 1: + # new_list.append(numb) + return new_list +print(my_function(my_list)) diff --git a/exercises/06.1-Everything_is_awesome/test.py b/exercises/06.1-Everything_is_awesome/test.py index e69de29b..f582b588 100644 --- a/exercises/06.1-Everything_is_awesome/test.py +++ b/exercises/06.1-Everything_is_awesome/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Output the new_list with the new items") +def test_output(): + captured = buffer.getvalue() + assert "[1, 'Yahoo', 'Yahoo', 'Yahoo', 1, 'Yahoo', 'Yahoo', 'Yahoo', 1, 1]\n" in captured + + +@pytest.mark.it("Using the conditional statement") +def test_conditional(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("if") > 0 + assert content.find("else") > 0 \ No newline at end of file diff --git a/exercises/07-Dowhile_DO_DO/README.md b/exercises/07-Dowhile_DO_DO/README.md index 2931ca6d..bf0261e5 100644 --- a/exercises/07-Dowhile_DO_DO/README.md +++ b/exercises/07-Dowhile_DO_DO/README.md @@ -1,8 +1,8 @@ -# `22` +# `07` D0 While -# Instructions from your teacher: DO DO DO The do{}while(); is another loop example in python is less commonly used but it is a loop +```py // stating value for the loop let i = 0; @@ -14,6 +14,7 @@ do { i++ // evaluate the value } while (i < 5); +``` #📝Instructions @@ -22,7 +23,7 @@ do { is a module of 5 2. At the end print() "LIFTOFF" -```js +```py Example Output on the console: 20! 19 diff --git a/exercises/08-Delete_element/README.md b/exercises/08-Delete_element/README.md index 848621e2..2acaf948 100644 --- a/exercises/08-Delete_element/README.md +++ b/exercises/08-Delete_element/README.md @@ -1,8 +1,8 @@ -# `23` -# Instructions from your teacher: +# `08` Delete element + The only way to delete `Daniella` from the list (without cheating) will be to create a new list with all the other people but Daniella. -📝Instructions +#📝Instructions 1. Please create a deletePerson function that deletes any given person from the list and returns a new list without that person. \ No newline at end of file diff --git a/exercises/08.1-Merge_list/README.md b/exercises/08.1-Merge_list/README.md index 64f09210..8f9c0b60 100644 --- a/exercises/08.1-Merge_list/README.md +++ b/exercises/08.1-Merge_list/README.md @@ -1,10 +1,19 @@ -# `24` Instructions from your teacher: +# `08.1` Merge List: Since we live in a new world, there should be no colors or labels, right? # 📝Instructions -1.Write a function that merges two arrays and returns a single new list +Write a function that merges two list and returns a single new list merging all the values of both lists. + 1. Declare an empty list. + 2. Loop the two list. + 3. Concatenate the result in an empty lists. + 4. Print the variable with two list + +```py + The console expected: + ['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas'] +``` 💡HINT: - You will have to loop though each list and insert their items into a new list. \ No newline at end of file diff --git a/exercises/08.1-Merge_list/app.py b/exercises/08.1-Merge_list/app.py index 0b03be60..cec90845 100644 --- a/exercises/08.1-Merge_list/app.py +++ b/exercises/08.1-Merge_list/app.py @@ -12,11 +12,3 @@ def merge_list(list1, list2): return merge print(merge_list(chunk_one, chunk_two)) - - - -def other(x1, x2): - for i in x2: - x1.append(i) - return x1 -print(other(chunk_one, chunk_two)) \ No newline at end of file diff --git a/exercises/08.1-Merge_list/test.py b/exercises/08.1-Merge_list/test.py index e69de29b..b154aeef 100644 --- a/exercises/08.1-Merge_list/test.py +++ b/exercises/08.1-Merge_list/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Mergin lists") +def test_merge(): + captured = buffer.getvalue() + assert "['Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell', 'Lucas', 'Jake', 'Scott', 'Amy', 'Molly', 'Hannah', 'Lucas']\n" in captured + +@pytest.mark.it("Use looping and return the new list") +def test_loop(): + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + assert content.find("return") > 0 \ No newline at end of file diff --git a/exercises/08.2-Divide_and_conquer/README.md b/exercises/08.2-Divide_and_conquer/README.md index 4daec313..bb90c422 100644 --- a/exercises/08.2-Divide_and_conquer/README.md +++ b/exercises/08.2-Divide_and_conquer/README.md @@ -1,4 +1,4 @@ -# `25` Instructions from your teacher: +# `08.2` Divide and conquer: #📝Instructions 1. Create a function called mergeTwoList that expects an list of numbers (integers). @@ -7,9 +7,9 @@ 4. If the number is even number push it to a placeholder list named even. 5. Then concatenate the odd list to the even list to combine them. Remember, the odd list comes first and you have to append the even mergeTwoList. -```js +```py Example: -mergeTwoList([1,2,33,10,20,4]); +mergeTwoList([1,2,33,10,20,4]) [1,33,2,10,20,4] ``` diff --git a/exercises/08.2-Divide_and_conquer/app.py b/exercises/08.2-Divide_and_conquer/app.py index 3eab6cf4..62bc97eb 100644 --- a/exercises/08.2-Divide_and_conquer/app.py +++ b/exercises/08.2-Divide_and_conquer/app.py @@ -4,14 +4,14 @@ #Your code here: -# odd_number = [] -# even_number = [] -# def merge_two_list(items): -# for i in items: -# if i % 2 != 0: -# odd_number.append(i) -# i += i -# else: -# even_number.append(i) -# return odd_number + even_number +odd_number = [] +even_number = [] +def merge_two_list(items): + for i in items: + if i % 2 != 0: + odd_number.append(i) + i += i + else: + even_number.append(i) + return odd_number + even_number print(merge_two_list(list_of_numbers)) \ No newline at end of file diff --git a/exercises/08.2-Divide_and_conquer/test.py b/exercises/08.2-Divide_and_conquer/test.py index e69de29b..f06bd9af 100644 --- a/exercises/08.2-Divide_and_conquer/test.py +++ b/exercises/08.2-Divide_and_conquer/test.py @@ -0,0 +1,26 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Odd and even numbers order by values") +def test_odd_even(): + captured = buffer.getvalue() + assert "[85, 59, 37, 25, 5, 81, 41, 55, 4, 80, 64, 66, 20, 64, 22, 76, 76, 96, 2, 68]\n" in captured + +@pytest.mark.it("Looping the list") +def test_for(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + +@pytest.mark.it("Conditional if/else") +def test_if_else(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("if") > 0 + assert content.find("else") > 0 \ No newline at end of file From b3cfd13906cef0a09208a906cce74ff5236bc70c Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 02:15:37 +0000 Subject: [PATCH 85/92] pytest exercises --- exercises/09-Max_integer_from_list/README.md | 12 +++++++----- exercises/09-Max_integer_from_list/app.py | 10 ++-------- exercises/09-Max_integer_from_list/test.py | 12 ++++++++++-- exercises/09.1-For_loop_min_value/README.md | 12 +++++++++--- exercises/09.1-For_loop_min_value/app.py | 14 ++++++++------ exercises/09.1-For_loop_min_value/test.py | 19 +++++++++++++++++++ 6 files changed, 55 insertions(+), 24 deletions(-) diff --git a/exercises/09-Max_integer_from_list/README.md b/exercises/09-Max_integer_from_list/README.md index 415b220a..30421a4c 100644 --- a/exercises/09-Max_integer_from_list/README.md +++ b/exercises/09-Max_integer_from_list/README.md @@ -1,14 +1,16 @@ -# `26` Instructions from your teacher: -Max integer from list +# `09` Max integer from my_list + + # 📝Instruccions -1. Write a script that finds the biggest integer in my_list - and print that number in the console with the print() function. +1. Write a script that finds the biggest integer in list +2. Print that number in the console with the print() function. 💡Hint: - Define an auxiliar variable and set the first value to 0. - then compare the variables with all the items in the list. - Replace the value every time the new element is bigger than the one stored in the auxiliar variable. - At the end you will have the biggest number stored in the variable. - ```js + + ```py Your result should be 5435. ``` \ No newline at end of file diff --git a/exercises/09-Max_integer_from_list/app.py b/exercises/09-Max_integer_from_list/app.py index a2b23460..8702810f 100644 --- a/exercises/09-Max_integer_from_list/app.py +++ b/exercises/09-Max_integer_from_list/app.py @@ -1,17 +1,11 @@ my_list = [43,23,6,87,43,1,4,6,3,67,8,3445,3,7,5435,63,346,3,456,734,6,34] -#Your code here: -"""the function it's not here, the student has to create the function from 0 to the end""" +#Your code go from here: -max_integer = my_list[0] +max_integer = 0 for i in my_list: if i > max_integer: max_integer = i print(max_integer) - -for i in range(len(my_list)): - if my_list[i] > max_integer: - max_integer.append(my_list[i]) -print(max_integer) \ No newline at end of file diff --git a/exercises/09-Max_integer_from_list/test.py b/exercises/09-Max_integer_from_list/test.py index 453423f6..0fe7aa04 100644 --- a/exercises/09-Max_integer_from_list/test.py +++ b/exercises/09-Max_integer_from_list/test.py @@ -1,4 +1,5 @@ import io +import os import sys sys.stdout = buffer = io.StringIO() @@ -10,5 +11,12 @@ @pytest.mark.it("Max integer from the list") def test_output(): - captured == buffer.getvalue() - assert "5435\n" in captured \ No newline at end of file + captured = buffer.getvalue() + assert "5435\n" in captured + +@pytest.mark.it("Use for loop and if statement") +def test_loo_if(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + assert content.find("if") > 0 \ No newline at end of file diff --git a/exercises/09.1-For_loop_min_value/README.md b/exercises/09.1-For_loop_min_value/README.md index 002214c9..6d65392d 100644 --- a/exercises/09.1-For_loop_min_value/README.md +++ b/exercises/09.1-For_loop_min_value/README.md @@ -1,10 +1,12 @@ -# `27` Instructions from your teacher: +# `09.1` Minimum integer: -It is possible to traverse an list using the list for loop, you have to specify what to do on each iteration of the loop. +It is possible to traverse an list using the list for loop, +you have to specify what to do on each iteration of the loop. # 📝Instructions -1. Please use the for loop function to get the minimum value of the list and print it in the console. +1. Please use the for loop function to get the minimum value + of the list and print it in the console. HINT 1. Declare an auxiliar global variable @@ -12,3 +14,7 @@ HINT 3. Every time you loop compare its value to the item value, if the item value is smaller update the auxiliar variable value to the item value. 4. Outside of the loop, after the loop is finished, print the auxiliar value. + +```py +expected: +``` \ No newline at end of file diff --git a/exercises/09.1-For_loop_min_value/app.py b/exercises/09.1-For_loop_min_value/app.py index e860c5d8..730c76f5 100644 --- a/exercises/09.1-For_loop_min_value/app.py +++ b/exercises/09.1-For_loop_min_value/app.py @@ -1,12 +1,14 @@ -my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335,43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63,425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523,566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644,35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] +my_list = [3344,34334,454543,342534,4563456,3445,23455,234,262,2335, +43323,4356,345,4545,452,345,434,36,345,4334,5454,345,4352,23,365,345,47,63, +425,6578759,768,834,754,35,32,445,453456,56,7536867,3884526,4234,35353245,53244523, +566785,7547,743,4324,523472634,26665,63432,54645,32,453625,7568,5669576,754,64356,542644, +35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] #Your code here: -"""the student have to create the algorism from 0 to complete""" - number = 999999999 -for i in my_list: - if i < number: - number = i +for min_numb in my_list: + if min_numb < number: + number = min_numb print(number) diff --git a/exercises/09.1-For_loop_min_value/test.py b/exercises/09.1-For_loop_min_value/test.py index e69de29b..5a1304dc 100644 --- a/exercises/09.1-For_loop_min_value/test.py +++ b/exercises/09.1-For_loop_min_value/test.py @@ -0,0 +1,19 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Print the minimum value from the list") +def test_min(): + captured = buffer.getvalue() + assert "23\n" in captured + +@pytest.mark.it("Use the for loop and if statemnent") +def test_if_loo(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + assert content.find("if") > 0 \ No newline at end of file From a8f3b5e2b44675a72aaa34ec62d4a98da0fb6598 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 03:48:07 +0000 Subject: [PATCH 86/92] for loop exercises --- exercises/10-Find_avg/README.md | 19 +++++++++-------- exercises/10-Find_avg/app.py | 7 +++---- exercises/10-Find_avg/test.py | 20 ++++++++++++++++++ .../README.md | 15 ++++++++++--- .../10.1-And_One_and_a_Two_and_a_Three/app.py | 18 +--------------- .../test.py | 21 +++++++++++++++++++ exercises/11-Nested_list/README.md | 17 +++++++++------ exercises/11-Nested_list/app.py | 11 +++------- exercises/11-Nested_list/test.py | 17 +++++++++++++++ exercises/12-Map_and_list/app.py | 7 ++----- 10 files changed, 100 insertions(+), 52 deletions(-) diff --git a/exercises/10-Find_avg/README.md b/exercises/10-Find_avg/README.md index 139b2195..ea7bc0b1 100644 --- a/exercises/10-Find_avg/README.md +++ b/exercises/10-Find_avg/README.md @@ -1,15 +1,16 @@ -# `28` Find average +# `10` Find average -Another way to loop a list with the for loop will be using the IN statement like this: - -```py -for index in my_list: - print(myArray[index]) -``` # 📝Instructions -Calculate the average value of all the items in the array and print it on the console. +1. Calculate the average value of all the items in the list and print it on the console. +2. # 💡HINT: -To print the average, you have to add all the values and divide the result by the total length of the array. \ No newline at end of file +To print the average, you have to add all the values and divide the result +by the total length of the list. + +```py +The result have to be like: +27278.8125 +``` diff --git a/exercises/10-Find_avg/app.py b/exercises/10-Find_avg/app.py index 9f3b75d8..86149ec8 100644 --- a/exercises/10-Find_avg/app.py +++ b/exercises/10-Find_avg/app.py @@ -3,9 +3,8 @@ #Your code here: -total = 0 - +# total = 0 for val in my_list: - total += val -avg = total / len(my_list) +# total += val +# avg = total / len(my_list) print(avg) diff --git a/exercises/10-Find_avg/test.py b/exercises/10-Find_avg/test.py index e69de29b..53c47d68 100644 --- a/exercises/10-Find_avg/test.py +++ b/exercises/10-Find_avg/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Print the minimum value from the list") +def test_min(): + captured = buffer.getvalue() + assert "27278.8125\n" in captured + +@pytest.mark.it("Use the for loop and len function") +def test_if_loo(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + assert content.find("len") > 0 \ No newline at end of file diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md index 4ee9938b..6887be4e 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md @@ -1,15 +1,24 @@ # `10.1` And one and two and three + +Dictionaries (or dict in Python) are a way of storing elements just like you +would in a Python list. But, rather than accessing elements using its index, +you assign a fixed key to it and access the element using the key. What you now +deal with is a "key-value" pair, which is sometimes a more appropriate data structure +for many problem instead of a simple list. + + # 📝Instruction 1. Given a contact object, please `loop all its properties and values` and print them on the console. 2. You will have to loop its properties to be able to print them ```py -Expected console output: +Example console output: fullname : John Doe phone : 123-123-2134 email : test@nowhere.com ``` 💡Hints -MDN for in loop reference - \ No newline at end of file +-contact.keys() #['fullname', 'phone', 'email'] +-contact.values() #['Jane Doe', '321-321-4321', 'test@test.com'] +-contact.items() #[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ('email', 'test@test.com')] diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py index 7783c82f..57eb8b1d 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -4,22 +4,6 @@ "email": "test@test.com" } #Your code here: - -# declare and aux variable and assign the value of the key -k = contact.keys() - - -# loop the entire dict and concactenate the items in one output for k, v in contact.items(): - print("{0}: {1}".format(k, v)) - - -#another form: -x = contact.keys() - -for x, e in contact.items(): - print(x, ":", e) + print(k, ":", v) -#loop without declaration: -for key, value in contact.items(): - print(key, ":", value) \ No newline at end of file diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py index e69de29b..6c3f02cf 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/test.py @@ -0,0 +1,21 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Print the items in the console") +def test_dict(): + captured = buffer.getvalue() + assert "fullname : Jane Doe\nphone : 321-321-4321\nemail : test@test.com\n" in captured + +@pytest.mark.it("Loop the all values") +def test_if_loo(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + + diff --git a/exercises/11-Nested_list/README.md b/exercises/11-Nested_list/README.md index 818e3208..8f1b78c9 100644 --- a/exercises/11-Nested_list/README.md +++ b/exercises/11-Nested_list/README.md @@ -1,19 +1,24 @@ -Instructions from your teacher: -# `29` Nested list + +# `11` Nested list + It is possible to find an list comprised of other lists (it is called a two-dimension list or matrix). In this example, we have a list of coordinates that you can access by doing the following: //longitude = [] // for loop in coordinate longitude -longitude = coordinatesArray[0][1]; +longitude = coordinatesList[0][1]; -Instructions: -Loop through the array printing only the longitudes. - +#📝Instructions: +Loop through the list printing only the longitudes. +```py The result should be something like this: -112.633853 -63.987 -81.901693 -71.653268 +``` + +💡Hint: +Remember the index of the position 1 is list[0] \ No newline at end of file diff --git a/exercises/11-Nested_list/app.py b/exercises/11-Nested_list/app.py index 9c3ae4ed..e3fe69f4 100644 --- a/exercises/11-Nested_list/app.py +++ b/exercises/11-Nested_list/app.py @@ -1,12 +1,7 @@ -coordinatesArray = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]] +coordinatesList = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]] # Your code go here: -"""from here the student have to decleare the function""" -"""declare the empty variable""" -# longitude = [] -# for grades in coordinatesArray: -# longitude.append(grades[1]) -# grades += grades -# print(longitude) +for grades in coordinatesList: + print(grades[1]) diff --git a/exercises/11-Nested_list/test.py b/exercises/11-Nested_list/test.py index 23aa2c4e..8f044e92 100644 --- a/exercises/11-Nested_list/test.py +++ b/exercises/11-Nested_list/test.py @@ -1,4 +1,21 @@ import io +import os import sys sys.stdout = buffer = io.StringIO() +import app +import pytest + + +@pytest.mark.it("Print the longitudes") +def test_dict(): + captured = buffer.getvalue() + assert "-112.633853\n-63.987\n-81.901693\n-71.653268\n" in captured + +@pytest.mark.it("Loop the all values using for loop") +def test_if_loo(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("for") > 0 + + diff --git a/exercises/12-Map_and_list/app.py b/exercises/12-Map_and_list/app.py index 31061ac0..6b995999 100644 --- a/exercises/12-Map_and_list/app.py +++ b/exercises/12-Map_and_list/app.py @@ -1,12 +1,9 @@ Celsius_values = [-2,34,56,-10] -fahrenheit_values = list(map(lambda x : x * 5 / 9 + 32, Celsius_values)) -print(fahrenheit_values) - - def fahrenheitValues(x): - return x * 5/9 + 32 +#the magic go here: + # return x * 5/9 + 32 result = list(map(fahrenheit_values, Celsius_values)) print(result) From 1a2584fa8f725a837ad426b580c399a9537e7bac Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 04:41:23 +0000 Subject: [PATCH 87/92] 12.2 readme --- exercises/12-Map_a_list/README.md | 32 +++++++++++++++++++ .../{12-Map_and_list => 12-Map_a_list}/app.py | 6 ++-- exercises/12-Map_a_list/test.py | 19 +++++++++++ exercises/12-Map_and_list/README.md | 2 -- exercises/12-Map_and_list/test.py | 0 exercises/12.1-more_mapping/README.md | 11 ++++--- exercises/12.1-more_mapping/app.py | 14 +++----- exercises/12.1-more_mapping/test.py | 21 ++++++++++++ .../README.md | 3 -- .../12.2-Map_function_inside_variable/app.py | 3 +- .../12.2-Map_function_inside_variable/test.py | 9 ++++++ 11 files changed, 95 insertions(+), 25 deletions(-) create mode 100644 exercises/12-Map_a_list/README.md rename exercises/{12-Map_and_list => 12-Map_a_list}/app.py (58%) create mode 100644 exercises/12-Map_a_list/test.py delete mode 100644 exercises/12-Map_and_list/README.md delete mode 100644 exercises/12-Map_and_list/test.py diff --git a/exercises/12-Map_a_list/README.md b/exercises/12-Map_a_list/README.md new file mode 100644 index 00000000..b8c5e31f --- /dev/null +++ b/exercises/12-Map_a_list/README.md @@ -0,0 +1,32 @@ +#`12` Map a list + +```py +Python map() +``` +The map() function applies a given function to each item of an iterable +(list, tuple etc.) and returns a list of the results. + +#The syntax of map() is: +```py +map(function, iterable, ...) +``` +#map() Parameter +`function - map()` passes each item of the iterable to this function. +iterable iterable which is to be mapped +You can pass more than one iterable to the map() function. + +#Return Value from map() +The map() function applies a given to function to each item of an iterable +and returns a list of the results. + +The returned value from map() (map object) then can be passed to functions +like list() (to create a list), set() (to create a set) and so on. + +#📝Instructions: +1. Using the same logic, add the needed code to convert a list of Celsius values +into Fahrenheit inside the map function. + +```py +Expected in console: +[28.4, 93.2, 132.8, 14.0] +``` diff --git a/exercises/12-Map_and_list/app.py b/exercises/12-Map_a_list/app.py similarity index 58% rename from exercises/12-Map_and_list/app.py rename to exercises/12-Map_a_list/app.py index 6b995999..49344ce6 100644 --- a/exercises/12-Map_and_list/app.py +++ b/exercises/12-Map_a_list/app.py @@ -2,8 +2,8 @@ -def fahrenheitValues(x): -#the magic go here: - # return x * 5/9 + 32 +def fahrenheit_values(x): +# the magic go here: + # return x * 9/5 + 32 result = list(map(fahrenheit_values, Celsius_values)) print(result) diff --git a/exercises/12-Map_a_list/test.py b/exercises/12-Map_a_list/test.py new file mode 100644 index 00000000..c9fe73db --- /dev/null +++ b/exercises/12-Map_a_list/test.py @@ -0,0 +1,19 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Print the longitudes") +def test_dict(): + captured = buffer.getvalue() + assert "[28.4, 93.2, 132.8, 14.0]\n" in captured + +@pytest.mark.it("Use map function") +def test_if_loo(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("map") > 0 \ No newline at end of file diff --git a/exercises/12-Map_and_list/README.md b/exercises/12-Map_and_list/README.md deleted file mode 100644 index 139597f9..00000000 --- a/exercises/12-Map_and_list/README.md +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/exercises/12-Map_and_list/test.py b/exercises/12-Map_and_list/test.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/12.1-more_mapping/README.md b/exercises/12.1-more_mapping/README.md index 0be12c65..26b8afc4 100644 --- a/exercises/12.1-more_mapping/README.md +++ b/exercises/12.1-more_mapping/README.md @@ -6,20 +6,21 @@ The list `map` method calls a function for each value in a list and then outputs a new list with the modified values. ```py - +#incrementByOne def values_list(number) { - return number + 1; + return number + 1 } my_list = [1, 2, 3, 4] -result = map(values_list,my_list) +result = map(values_list, my_list) #returns [2, 3, 4, 5] ``` # 📝Instructions: 1. Create a function named increment_by_one that will multiply each number by 3. -2. Use the list map() function to run the increment_by_one function through each value in the list. -3. Store the new list in a variable named total and print() the new list. +2.Pass a argument into the function +3. Use the list map() function to run the increment_by_one function through each value in the list. +4. Store the new list in a variable named total and print() the new list. 💡Hint: The function will take a parameter with the original item being transformed and added into the new list. diff --git a/exercises/12.1-more_mapping/app.py b/exercises/12.1-more_mapping/app.py index e3da93ea..2b80373a 100644 --- a/exercises/12.1-more_mapping/app.py +++ b/exercises/12.1-more_mapping/app.py @@ -1,14 +1,8 @@ myNumbers = [23,234,345,4356234,243,43,56,2] -result = list(map(lambda x: x * 3, myNumbers)) -print(result) +def increment_by_one(numbers): + return numbers * 3 - - -# other sample -def other_sample(x): - return x * 3 - -result = list(map(other_sample, myNumbers)) -print(result) +result = list(map(increment_by_one, myNumbers)) +print(result) \ No newline at end of file diff --git a/exercises/12.1-more_mapping/test.py b/exercises/12.1-more_mapping/test.py index e69de29b..be45cd14 100644 --- a/exercises/12.1-more_mapping/test.py +++ b/exercises/12.1-more_mapping/test.py @@ -0,0 +1,21 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Result of multiply by 3") +def test_multp(): + captured = buffer.getvalue() + assert "[69, 702, 1035, 13068702, 729, 129, 168, 6]\n" in captured + +@pytest.mark.it("Use the map() function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("map") > 0 + + + diff --git a/exercises/12.2-Map_function_inside_variable/README.md b/exercises/12.2-Map_function_inside_variable/README.md index bf532d33..08468d1b 100644 --- a/exercises/12.2-Map_function_inside_variable/README.md +++ b/exercises/12.2-Map_function_inside_variable/README.md @@ -9,6 +9,3 @@ The function stored in the variable prepender returns whatever is passed to it 1. Please map the names list using the prepender function to create a new list that looks like this: !["Map function"](https://storage.googleapis.com/replit/images/1525912878195_89876a082d32ee32bb7a1ab5834dbca0.pn) - -💡Hint: -It's one line of code, pass the function to the map! \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index 7398239b..3da594ab 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -2,5 +2,4 @@ def prepender(name): return "My name is: " + name -result = list(map(prepender, names)) -print(result) +print(list(map(prepender, names))) \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/test.py b/exercises/12.2-Map_function_inside_variable/test.py index e69de29b..50bc37dd 100644 --- a/exercises/12.2-Map_function_inside_variable/test.py +++ b/exercises/12.2-Map_function_inside_variable/test.py @@ -0,0 +1,9 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("") \ No newline at end of file From 9583cf8a01dc984b81570f00c94889ad1b452685 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 15:01:47 +0000 Subject: [PATCH 88/92] pytest exercises --- exercises/05-Sum_all_items/app.py | 8 +---- .../README.md | 4 ++- .../12.2-Map_function_inside_variable/app.py | 3 +- .../12.2-Map_function_inside_variable/test.py | 9 +++++- exercises/12.3-Map_data_types/README.md | 2 +- exercises/12.3-Map_data_types/app.py | 6 +--- exercises/12.3-Map_data_types/test.py | 20 +++++++++++++ exercises/12.4-Map_list_of_objects/README.md | 9 +++--- exercises/12.4-Map_list_of_objects/app.py | 6 +--- exercises/12.4-Map_list_of_objects/test.py | 13 ++++++++ exercises/12.5-Yes_and_no/README.md | 18 +++++++++++ exercises/12.5-Yes_and_no/app.py | 6 ++-- exercises/12.5-Yes_and_no/test.py | 30 +++++++++++++++++++ exercises/12.6-Transformers/README.md | 12 ++++++++ exercises/12.6-Transformers/app.py | 10 +++---- exercises/12.6-Transformers/test.py | 20 +++++++++++++ 16 files changed, 141 insertions(+), 35 deletions(-) diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 49bf62aa..923ff5be 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -10,10 +10,4 @@ def sum_all_values(items): total += items[i] return total -print(sum_all_values(my_sample_list)) - - - -#can use this too -# for i in items: -# total += i +print(sum_all_values(my_sample_list)) \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/README.md b/exercises/12.2-Map_function_inside_variable/README.md index 08468d1b..ea2c056f 100644 --- a/exercises/12.2-Map_function_inside_variable/README.md +++ b/exercises/12.2-Map_function_inside_variable/README.md @@ -6,6 +6,8 @@ The function stored in the variable prepender returns whatever is passed to it but prepended with the string: 'My name is:' #📝Instructions -1. Please map the names list using the prepender function to create a new list that looks like this: +1. Please map the names list using the prepender function +to create a new list that looks like this: + !["Map function"](https://storage.googleapis.com/replit/images/1525912878195_89876a082d32ee32bb7a1ab5834dbca0.pn) diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index 3da594ab..4c8c393e 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -2,4 +2,5 @@ def prepender(name): return "My name is: " + name -print(list(map(prepender, names))) \ No newline at end of file +print(list(map(prepender, names))) + diff --git a/exercises/12.2-Map_function_inside_variable/test.py b/exercises/12.2-Map_function_inside_variable/test.py index 50bc37dd..a1fa2361 100644 --- a/exercises/12.2-Map_function_inside_variable/test.py +++ b/exercises/12.2-Map_function_inside_variable/test.py @@ -6,4 +6,11 @@ import app import pytest -@pytest.mark.it("") \ No newline at end of file +@pytest.mark.it("") + + +@pytest.mark.it("Awesome you use the map function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("map") > 0 \ No newline at end of file diff --git a/exercises/12.3-Map_data_types/README.md b/exercises/12.3-Map_data_types/README.md index ec9dd552..a4952193 100644 --- a/exercises/12.3-Map_data_types/README.md +++ b/exercises/12.3-Map_data_types/README.md @@ -7,7 +7,7 @@ types of each corresponding item from the original list. The result in the console should be something like: ```py -[string,string,... ,number,string,...] +[, , , , , , , ] ``` 💡Hint: diff --git a/exercises/12.3-Map_data_types/app.py b/exercises/12.3-Map_data_types/app.py index 8713429d..eb6330b3 100644 --- a/exercises/12.3-Map_data_types/app.py +++ b/exercises/12.3-Map_data_types/app.py @@ -1,4 +1,4 @@ -list_of_Strings = ['1','5','45','34','343','34',6556,323] +list_Strings = ['1','5','45','34','343','34',6556,323] def type_list(items): @@ -8,8 +8,4 @@ def type_list(items): print(result) -#this return the same -type_data = lambda data: (type(data)) -sample = list(map(type_data, list_Strings)) -print(sample) diff --git a/exercises/12.3-Map_data_types/test.py b/exercises/12.3-Map_data_types/test.py index e69de29b..4f3b7f1b 100644 --- a/exercises/12.3-Map_data_types/test.py +++ b/exercises/12.3-Map_data_types/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Output all data types of the list") +def test_type(): + captured = buffer.getvalue() + assert "[, , , , , , , ]\n" in captured + + +@pytest.mark.it("Use the map function to return the data type") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("map") > 0 \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/README.md b/exercises/12.4-Map_list_of_objects/README.md index 65cad718..0efdafab 100644 --- a/exercises/12.4-Map_list_of_objects/README.md +++ b/exercises/12.4-Map_list_of_objects/README.md @@ -8,17 +8,18 @@ The current algorithm creates a lists with only the names of the people and prin 1. Please update the mapping function so it creates a list where each item contains the following: -Hello my name is Joe and I am 13 years old. +`Hello my name is Joe and I am 13 years old.` 💡Hint -You have to get the age of each people based on their birthDate. Search in Google "How to get the age of given birth date in python" +You have to get the age of each people based on their birthDate. +Search in Google "How to get the age of given birth date in python" Inside your simplifier function you have to return a concatenation. The expected output should look similar but not exactly to this: - +```py [ 'Hello, my name is Joe and I am 32 years old', 'Hello, my name is Bob and I am 42 years old', 'Hello, my name is Erika and I am 28 years old', 'Hello, my name is Dylan and I am 18 years old', 'Hello, my name is Steve and I am 14 years old' ] - +``` \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index b5f8bcbe..7519d32a 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -16,8 +16,4 @@ def calculateAge(birthDate): name_list = list(map(lambda x: "Hello my name is " + str(x["name"]) + " and I am " + calculateAge(date(int(x["birthDate"]))) + " years old", people)) -print(str(name_list)) - - -#revisar esto -#esta devolviendo los names y un solo parametro the los años \ No newline at end of file +print(str(name_list)) \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/test.py b/exercises/12.4-Map_list_of_objects/test.py index e69de29b..459fd557 100644 --- a/exercises/12.4-Map_list_of_objects/test.py +++ b/exercises/12.4-Map_list_of_objects/test.py @@ -0,0 +1,13 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("") + + + +@pytest.mark.it("") \ No newline at end of file diff --git a/exercises/12.5-Yes_and_no/README.md b/exercises/12.5-Yes_and_no/README.md index e69de29b..6b6830f6 100644 --- a/exercises/12.5-Yes_and_no/README.md +++ b/exercises/12.5-Yes_and_no/README.md @@ -0,0 +1,18 @@ +#`12.5` Yes and no + +#📝Instructions +1. Please use the list map functionality to loop the list of booleans and create a new list + that contains the string 'wiki' for every 1 and 'woko' for every 0 that the original list had. +2. Print that list on the console. + +```py +Example output: + +[ 'woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki' ] +``` + +Hint +You need to map the entire list +Inside your mapping function you need to use a conditional to verify if the current value is 0 or 1. +If the current value is 1 you print the string 'wiki' +If the current value is 0 you print the string 'woko' \ No newline at end of file diff --git a/exercises/12.5-Yes_and_no/app.py b/exercises/12.5-Yes_and_no/app.py index dd34fd0f..c8947684 100644 --- a/exercises/12.5-Yes_and_no/app.py +++ b/exercises/12.5-Yes_and_no/app.py @@ -1,5 +1,7 @@ theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1] + + def other(numbers): if numbers == 1: return "wiki" @@ -9,7 +11,3 @@ def other(numbers): print(result) - -rate = lambda x : "wiki" if (x == 1) else "woko" -sample = list(map(rate, theBools)) -print(sample) diff --git a/exercises/12.5-Yes_and_no/test.py b/exercises/12.5-Yes_and_no/test.py index e69de29b..327f60c3 100644 --- a/exercises/12.5-Yes_and_no/test.py +++ b/exercises/12.5-Yes_and_no/test.py @@ -0,0 +1,30 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Congratulation!!!, that was a nice work") +def test_output(): + captured = buffer.getvalue() + assert "['woko', 'wiki', 'woko', 'woko', 'wiki', 'wiki', 'wiki', 'woko', 'woko', 'wiki', 'woko', 'wiki', 'wiki', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'woko', 'wiki', 'woko', 'woko', 'woko', 'woko', 'wiki']\n" in captured + +@pytest.mark.it("Using map function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("map") > 0 + +def test_if(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("if") > 0 + +def test_else(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("else") > 0 + diff --git a/exercises/12.6-Transformers/README.md b/exercises/12.6-Transformers/README.md index e69de29b..d385997a 100644 --- a/exercises/12.6-Transformers/README.md +++ b/exercises/12.6-Transformers/README.md @@ -0,0 +1,12 @@ +#`12.6` Transformers + +#📝Instructions + +1. Declare a new variable called transformedData and fill it with a list of +strings containing the full name of each user. + +```py +The expected output + +'Mario Montes', 'Joe Biden', 'Bill Clon', 'Hilary Mccafee', 'Bobby Mc birth'] +``` \ No newline at end of file diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py index de3a887e..c2da8ccc 100644 --- a/exercises/12.6-Transformers/app.py +++ b/exercises/12.6-Transformers/app.py @@ -6,13 +6,11 @@ { "name": 'Bobby', "lastName": 'Mc birth' } ] -#return the dict into the list -all_people = list(map(lambda p: p["name"] + " " + p["lastName"], incomingAJAXData)) -print(all_people) -#function return dict into the list def my_function(items): return items['name'] +' '+items['lastName'] -result = list(map(my_function, incomingAJAXData)) -print(result) +transformed_data = list(map(my_function, incomingAJAXData)) +print(transformed_data) + + diff --git a/exercises/12.6-Transformers/test.py b/exercises/12.6-Transformers/test.py index e69de29b..e7400264 100644 --- a/exercises/12.6-Transformers/test.py +++ b/exercises/12.6-Transformers/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + + +@pytest.mark.it("Nice work!!! the transformed_data variable is passed") +def test_output(): + captured = buffer.getvalue() + assert "['Mario Montes', 'Joe Biden', 'Bill Clon', 'Hilary Mccafee', 'Bobby Mc birth']\n" in captured + +@pytest.mark.it("Using map function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("map") > 0 \ No newline at end of file From 9730b614c23b3880ac1f7a8bb8aacff765a1cdcb Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 15:32:08 +0000 Subject: [PATCH 89/92] pytest exercises --- exercises/13-Filter_list/README.md | 2 -- exercises/13-Filter_list/app.py | 15 +++------------ exercises/13-Filter_list/test.py | 20 ++++++++++++++++++++ exercises/13.1-Filter_and_list/README.md | 18 +++++++++++------- exercises/13.1-Filter_and_list/app.py | 14 ++++---------- exercises/13.1-Filter_and_list/test.py | 20 ++++++++++++++++++++ exercises/13.2-filter_done_tasks/README.md | 4 +--- exercises/13.2-filter_done_tasks/app.py | 7 +------ exercises/13.2-filter_done_tasks/test.py | 20 ++++++++++++++++++++ exercises/13.3-Filter_list_strings/README.md | 11 ++++++++--- exercises/13.3-Filter_list_strings/app.py | 12 ++++++------ exercises/13.3-Filter_list_strings/test.py | 20 ++++++++++++++++++++ 12 files changed, 114 insertions(+), 49 deletions(-) diff --git a/exercises/13-Filter_list/README.md b/exercises/13-Filter_list/README.md index 68cbd561..c6b610b1 100644 --- a/exercises/13-Filter_list/README.md +++ b/exercises/13-Filter_list/README.md @@ -1,9 +1,7 @@ #`13` Filter list Another looping function that is available on python is the `filter function`. - Its main purpose is to remove elements from the original list and return a new list with the result. - The code on the left is filtering the odd numbers from the allNumbers list. #📝Instructions diff --git a/exercises/13-Filter_list/app.py b/exercises/13-Filter_list/app.py index c0ac145f..dd6ccd61 100644 --- a/exercises/13-Filter_list/app.py +++ b/exercises/13-Filter_list/app.py @@ -1,17 +1,8 @@ allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] -result = filter(lambda x: x > 10, allNumbers) -total = set(result) -print(total) - - - -#the same result -def sample(items): +def filter_function(items): return items > 10 -other_list = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] -return_list = filter(sample, other_list) -aux = set(return_list) -print(aux) \ No newline at end of file +greater_than = list(filter(filter_function, allNumbers)) +print(greater_than) \ No newline at end of file diff --git a/exercises/13-Filter_list/test.py b/exercises/13-Filter_list/test.py index e69de29b..e3bb2c0f 100644 --- a/exercises/13-Filter_list/test.py +++ b/exercises/13-Filter_list/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + + +@pytest.mark.it("Good!!! 😎 Maybe your are smart!!!") +def test_output(): + captured = buffer.getvalue() + assert "[23, 12, 35, 54, 21, 534, 23, 42]\n" in captured + +@pytest.mark.it("Using filter function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("filter") > 0 \ No newline at end of file diff --git a/exercises/13.1-Filter_and_list/README.md b/exercises/13.1-Filter_and_list/README.md index 7134ff06..6c400e89 100644 --- a/exercises/13.1-Filter_and_list/README.md +++ b/exercises/13.1-Filter_and_list/README.md @@ -2,14 +2,17 @@ this is another example using filter list in python -For example, this algorithm filters the allNumbers list and returns a new list with only the odds numbers: +For example, this algorithm filters the allNumbers list and returns + a new list with only the odds numbers: ```py allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] -result = filter(lambda x: x % 2 > 0, allNumbers) -return_list = set(result) -print(return_list) +def myFunction(numb): + return numb % 2 == 0 + +oddNumbers = list(filter(myFunction, allNumbers)) +print(oddNumbers) ``` @@ -18,6 +21,7 @@ print(return_list) 1. Complete the code to make it fill the resultingNames list with only the names that start with letter R 2. Use the filter function - \ No newline at end of file +```py +The console expected: +['Romario', 'Roosevelt'] +``` \ No newline at end of file diff --git a/exercises/13.1-Filter_and_list/app.py b/exercises/13.1-Filter_and_list/app.py index 42c47dd8..4a4dc67e 100644 --- a/exercises/13.1-Filter_and_list/app.py +++ b/exercises/13.1-Filter_and_list/app.py @@ -1,19 +1,13 @@ -#using lambda -allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] -result = filter(lambda x: x.startswith("R"), allNames) -return_list = set(result) -print(return_list) +allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] -#the same result -def my_function(names): +def persons(names): if 'R' in names: return True else: return False -my_filter_function = filter(my_function, allNames) -result = set(my_filter_function) -print(result) +resultingNames = list(filter(persons, allNames)) +print(resultingNames) diff --git a/exercises/13.1-Filter_and_list/test.py b/exercises/13.1-Filter_and_list/test.py index e69de29b..0f67a6c3 100644 --- a/exercises/13.1-Filter_and_list/test.py +++ b/exercises/13.1-Filter_and_list/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + + +@pytest.mark.it("Cool!!! 🤩 You have names only with 'R' ") +def test_output(): + captured = buffer.getvalue() + assert "['Romario', 'Roosevelt']\n" in captured + +@pytest.mark.it("Using filter function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("filter") > 0 \ No newline at end of file diff --git a/exercises/13.2-filter_done_tasks/README.md b/exercises/13.2-filter_done_tasks/README.md index 7a7b63e3..ee049093 100644 --- a/exercises/13.2-filter_done_tasks/README.md +++ b/exercises/13.2-filter_done_tasks/README.md @@ -6,7 +6,5 @@ ```py Expected output: -[ { label: 'Eat my lunch', done: true }, - { label: 'Replit the finishes', done: true }, - { label: 'Read a book', done: true } ] +[{'label': 'Eat my lunch', 'done': True}, {'label': 'Replit the finishes', 'done': True}, {'label': 'Read a book', 'done': True}] ``` \ No newline at end of file diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py index 8a8b2798..80da5200 100644 --- a/exercises/13.2-filter_done_tasks/app.py +++ b/exercises/13.2-filter_done_tasks/app.py @@ -1,3 +1,4 @@ + tasks = [ { "label": 'Eat my lunch', "done": True }, { "label": 'Make the bed', "done": False }, @@ -11,13 +12,7 @@ - -#using function def my_function(items): return items['done'] result = list(filter(my_function, tasks)) print(result) - -#lambda expretion -done_tasks = list(filter(lambda x: x['done'], tasks)) -print(done_tasks) \ No newline at end of file diff --git a/exercises/13.2-filter_done_tasks/test.py b/exercises/13.2-filter_done_tasks/test.py index e69de29b..b7c11491 100644 --- a/exercises/13.2-filter_done_tasks/test.py +++ b/exercises/13.2-filter_done_tasks/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + + +@pytest.mark.it("Good job!!! 😃 the True tasks are passed") +def test_output(): + captured = buffer.getvalue() + assert "[{'label': 'Eat my lunch', 'done': True}, {'label': 'Replit the finishes', 'done': True}, {'label': 'Read a book', 'done': True}]\n" in captured + +@pytest.mark.it("Using filter function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("filter") > 0 \ No newline at end of file diff --git a/exercises/13.3-Filter_list_strings/README.md b/exercises/13.3-Filter_list_strings/README.md index ff44b270..3d8415c1 100644 --- a/exercises/13.3-Filter_list_strings/README.md +++ b/exercises/13.3-Filter_list_strings/README.md @@ -2,8 +2,13 @@ #📝Instructions: -1. Given a list names please create a function filters the list with only the names that contain the given string. -2. Create a function called filteringList that take two values one is the list and second one is the filter desire. +1. Given a list names please create a function filters the list with only + the names that contain the given string. +2. Create a function called filteringList that take two values one is the + list and second one is the filter desire. 3. The search should NOT be Case Sensitive. - +```py +Result: +['Liam', 'William', 'James', 'Benjamin', 'Samuel', 'Camila'] +``` \ No newline at end of file diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index d947ea5c..1132dd2b 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -1,4 +1,9 @@ -names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia','Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail','Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia','Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria','Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] + +names = ['Liam','Emma','Noah','Olivia','William','Ava','James','Isabella','Logan','Sophia', +'Benjamin','Mia','Mason','Charlotte','Elijah','Amelia','Oliver','Evelyn','Jacob','Abigail', +'Lucas','Harper','Michael','Emily','Alexander','Elizabeth','Ethan','Avery','Daniel','Sofia', +'Matthew','Ella','Aiden','Madison','Henry','Scarlett','Joseph','Victoria','Jackson','Aria', +'Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] @@ -10,8 +15,3 @@ def filteringList(word): my_names = list(filter(filteringList, names)) print(my_names) - - - -my_names = [s for s in names if 'am' in s] -print(my_names) \ No newline at end of file diff --git a/exercises/13.3-Filter_list_strings/test.py b/exercises/13.3-Filter_list_strings/test.py index e69de29b..0efce2a7 100644 --- a/exercises/13.3-Filter_list_strings/test.py +++ b/exercises/13.3-Filter_list_strings/test.py @@ -0,0 +1,20 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + + +@pytest.mark.it("Awesome!!!🤓You have the persons with parameter include") +def test_output(): + captured = buffer.getvalue() + assert "['Liam', 'William', 'James', 'Benjamin', 'Samuel', 'Camila']\n" in captured + +@pytest.mark.it("Using filter function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("filter") > 0 \ No newline at end of file From 606f85ef6e535f9239f4783797bdef3332e33322 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 14 Sep 2019 21:10:19 +0000 Subject: [PATCH 90/92] map list --- exercises/01-hello-world/app.py | 4 +++- exercises/01-hello-world/test.py | 14 ++++++++--- exercises/01.1-Access-and-Retrieve/app.py | 6 ++--- exercises/01.2-Retrieve-items/app.py | 3 +-- exercises/01.3-Print-the-last-one/app.py | 2 -- exercises/01.3-Print-the-last-one/test.py | 16 +++++++++---- exercises/01.4-Add-item-to-list/app.py | 6 ++--- exercises/01.4-Add-item-to-list/test.py | 9 +++++++- exercises/01.5-loop-seventeen/app.py | 2 -- exercises/01.5-loop-seventeen/test.py | 5 ++-- exercises/02-Loop-list/app.py | 13 ++--------- exercises/02-Loop-list/test.py | 3 +-- exercises/02.1-Loop-from-the-top/README.md | 5 ---- exercises/02.1-Loop-from-the-top/app.py | 5 ++-- exercises/02.2-Loop-adding-two/app.py | 5 +--- .../02.3-loop-from-the-half-to-the-end/app.py | 10 ++++---- exercises/02.4-One_last_looping/app.py | 13 ----------- exercises/02.5-Finding_wally/app.py | 4 ---- exercises/02.5-Finding_wally/test.py | 9 +++++++- exercises/02.6-letter_counter/README.md | 5 ++-- exercises/02.6-letter_counter/app.py | 11 +++------ exercises/02.6-letter_counter/test.py | 17 ++++++++++++-- exercises/03-flip_list/app.py | 6 +---- exercises/04-mixed_list/app.py | 14 ----------- exercises/04.1-count_on/README.md | 14 ++++++----- exercises/04.1-count_on/app.py | 4 +++- exercises/05-Sum_all_items/app.py | 6 ++--- exercises/05.1-sum_odd_items/app.py | 8 +------ exercises/06-forEach_loop/app.py | 5 ++-- exercises/06.1-Everything_is_awesome/app.py | 5 +--- exercises/06.1-Everything_is_awesome/test.py | 1 + exercises/07-Dowhile_DO_DO/README.md | 5 ++-- exercises/08-Delete_element/README.md | 10 +++++++- exercises/08-Delete_element/app.py | 17 ++++++++++++++ exercises/08-Delete_element/test.py | 23 +++++++++++++++++++ exercises/08.1-Merge_list/app.py | 10 ++------ exercises/08.2-Divide_and_conquer/app.py | 13 ++--------- exercises/09-Max_integer_from_list/app.py | 6 ----- exercises/09.1-For_loop_min_value/app.py | 7 ------ exercises/10-Find_avg/README.md | 4 ++-- exercises/10-Find_avg/app.py | 10 ++++---- .../10.1-And_One_and_a_Two_and_a_Three/app.py | 2 -- exercises/11-Nested_list/app.py | 3 +-- exercises/12.1-more_mapping/app.py | 7 ++---- .../12.2-Map_function_inside_variable/app.py | 3 +-- exercises/12.3-Map_data_types/app.py | 9 +++----- exercises/12.4-Map_list_of_objects/app.py | 2 +- exercises/12.5-Yes_and_no/app.py | 10 +------- exercises/12.6-Transformers/app.py | 7 +----- exercises/13-Filter_list/app.py | 3 +-- exercises/13.1-Filter_and_list/app.py | 8 +------ exercises/13.2-filter_done_tasks/app.py | 6 +---- exercises/13.3-Filter_list_strings/app.py | 10 +------- .../README.md} | 0 .../app.py | 13 +++++++++++ .../test.py | 0 .../app.py | 0 57 files changed, 191 insertions(+), 227 deletions(-) rename exercises/{13.4-Making_HTML_with_filter_and_map/RAEDME.md => 13.4-Making_HTML_with_filter_and_maP/README.md} (100%) create mode 100644 exercises/13.4-Making_HTML_with_filter_and_maP/app.py rename exercises/{13.4-Making_HTML_with_filter_and_map => 13.4-Making_HTML_with_filter_and_maP}/test.py (100%) delete mode 100644 exercises/13.4-Making_HTML_with_filter_and_map/app.py diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py index 8489699e..6ffb617d 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,3 +1,5 @@ + + #You have to print `hello` in the console, your code go here: -print("hello") +print("Hello World") diff --git a/exercises/01-hello-world/test.py b/exercises/01-hello-world/test.py index 03d03d8a..ca104630 100644 --- a/exercises/01-hello-world/test.py +++ b/exercises/01-hello-world/test.py @@ -1,5 +1,6 @@ import io import sys +import os sys.stdout = buffer = io.StringIO() # from app import my_function @@ -21,8 +22,15 @@ # def test_for_function_return(capsys): # assert my_function() == True -@pytest.mark.it("Output 'Hello'") +@pytest.mark.it("Output 'Hello World'") def test_output(): captured = buffer.getvalue() - assert "hello\n" in captured - # convert everything in the buffer to lower case, captured to lower case \ No newline at end of file + assert "Hello World\n" in captured + # convert everything in the buffer to lower case, captured to lower case + + +@pytest.mark.it("Use print function") +def test_print(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("print") > 0 \ No newline at end of file diff --git a/exercises/01.1-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py index 02bcae4d..39ff0606 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -2,9 +2,9 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_list[2]) + #2. change 'thursday'a value here to None -my_list[4] = None + #3. print the position of step 2 -print(my_list[4]) + diff --git a/exercises/01.2-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py index 7d46a1b3..d4305d84 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -1,6 +1,5 @@ my_list = [4,5,734,43,45,100,4,56,23,67,23,58,45,3,100,4,56,23] #output the 1st and 4th element from the list: -print(my_list[0]) -print(my_list[3]) + diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index 682e7fa4..f33009bc 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -12,5 +12,3 @@ def generate_random_list(): my_stupid_list = generate_random_list() #Feel happy to write the code below, good luck: -the_last_one = my_stupid_list[-1] -print(the_last_one) \ No newline at end of file diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index 89f8ab19..b06bdf6e 100644 --- a/exercises/01.3-Print-the-last-one/test.py +++ b/exercises/01.3-Print-the-last-one/test.py @@ -3,8 +3,10 @@ import app import pytest +import os from app import the_last_one + sys.stdout = buffer = io.StringIO() @pytest.mark.it("create and assign the value to the variable the_last_one") @@ -12,7 +14,13 @@ def test_create_assign(): assert app.the_last_one is not None -@pytest.mark.it("print in the console the_last_one") -def test_output(): - captured = buffer.getvalue() - assert str(app.the_last_one) in captured +# @pytest.mark.it("print in the console the_last_one") +# def test_output(): +# captured = buffer.getvalue() +# assert str(app.the_last_one) in captured + +@pytest.mark.it("Import random function") +def test_import_random(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("import random") > 0 diff --git a/exercises/01.4-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py index a31b9eac..440a98e8 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -1,10 +1,10 @@ #Remember import random function here: -import random + my_list = [4,5,734,43,45] #The magic is here: -for num in range(1, 11): - my_list.append(random.randint(1, 100)) + + print(my_list) diff --git a/exercises/01.4-Add-item-to-list/test.py b/exercises/01.4-Add-item-to-list/test.py index d253d0ad..20bf728b 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -4,6 +4,7 @@ import pytest import app +import os import random from app import my_list @@ -14,4 +15,10 @@ def test_add_numb(): @pytest.mark.it("Output of the list with 15 items numbers") def test_output(): captured = buffer.getvalue() - assert str(app.my_list) in captured \ No newline at end of file + assert str(app.my_list) in captured + +@pytest.mark.it("Import random function") +def test_import_random(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("import random") > 0 diff --git a/exercises/01.5-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py index 7dc2e8e7..38e47b7d 100644 --- a/exercises/01.5-loop-seventeen/app.py +++ b/exercises/01.5-loop-seventeen/app.py @@ -1,3 +1 @@ #Your code here, have fun: -for numb in range(1,18): - print(numb) \ No newline at end of file diff --git a/exercises/01.5-loop-seventeen/test.py b/exercises/01.5-loop-seventeen/test.py index c6fe9b06..f21c6053 100644 --- a/exercises/01.5-loop-seventeen/test.py +++ b/exercises/01.5-loop-seventeen/test.py @@ -14,10 +14,9 @@ def test_output(): -@pytest.mark.it("Make sure that there is a 'for loop' in your code") +@pytest.mark.it("Make sure that you use for loop!!!") def test_for_loop(): - captured = buffer.getvalue() f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') content = f.read() - assert content.find("for ") > 0 + assert content.find("for") > 0 diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index d06155f9..b2ab27c2 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,13 +1,4 @@ my_list = [232,32,1,4,55,4,3,32,3,24,5,5,5,34,2,35,5365743,52,34,3,55] -#You don't to change nothing above, your code go below: - -for numbers in my_list: - print(my_list) - - - - -#another for -#for index in range(len(my_list)): -# print(my_list[index]) \ No newline at end of file +#Your code go here: +print(my_list[0]) \ No newline at end of file diff --git a/exercises/02-Loop-list/test.py b/exercises/02-Loop-list/test.py index 66a42606..3039a498 100644 --- a/exercises/02-Loop-list/test.py +++ b/exercises/02-Loop-list/test.py @@ -15,8 +15,7 @@ def test_output(): @pytest.mark.it("Be sure that you use the for loop in the exercises") def test_use_forLoop(): - captured = buffer.getvalue() f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') content = f.read() - assert content.find("for ") > 0 \ No newline at end of file + assert content.find("for") > 0 \ No newline at end of file diff --git a/exercises/02.1-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md index 42bca118..4dda8577 100644 --- a/exercises/02.1-Loop-from-the-top/README.md +++ b/exercises/02.1-Loop-from-the-top/README.md @@ -6,11 +6,6 @@ This loop is `looping` the list from beginning to end... increasing one by one. # 📝Instructions Lets try looping from the end to the beginning. -💡HINT -1. Remember the loop works like this: https://www.youtube.com/watch?v=TSMzvFwpE_A -2. The last position of the list will be variable_name[-1] because list start at 0 - - The console output should be something like this: ```js 12 diff --git a/exercises/02.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py index 83e9b65d..2b4e6a31 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -1,8 +1,7 @@ my_sample_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] -#nothing change above, the magic pass below: +#The magic pass below: -for i in range(len(my_sample_list)): - print(my_sample_list[-i-1]) + diff --git a/exercises/02.2-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py index 819e4476..a335d15b 100644 --- a/exercises/02.2-Loop-adding-two/app.py +++ b/exercises/02.2-Loop-adding-two/app.py @@ -3,9 +3,6 @@ #your code go below of this line, nothing change above: -for i in range(0, len(my_sample_list), 2): +for i in range(0, len(my_sample_list), 1): print(my_sample_list[i]) -# # for i in my_sample_list[0::2]: -# # print(i) - diff --git a/exercises/02.3-loop-from-the-half-to-the-end/app.py b/exercises/02.3-loop-from-the-half-to-the-end/app.py index f5ffd1d4..b54d88af 100644 --- a/exercises/02.3-loop-from-the-half-to-the-end/app.py +++ b/exercises/02.3-loop-from-the-half-to-the-end/app.py @@ -1,11 +1,11 @@ my_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] -#Your code here: -inicialValue = 7 -stopValue = 14 -increaseValue = 1 +#Your code here: +inicialValue = 0 +stopValue = 0 +increaseValue = 0 for i in range(inicialValue, stopValue): if i == my_list[i]: i += increaseValue - print(my_list[i]) \ No newline at end of file + print(my_list[i]) diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index e6afa2fe..c2d1a72c 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -1,16 +1,3 @@ my_sample_list = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie'] #Your code here: - -my_sample_list[1] = "Steve" -my_sample_list[-1] = "Pepe" -my_sample_list[0] = my_sample_list[2] + my_sample_list[4] - - -# new_list = [] -# for names in range(len(my_sample_list)): -# new_list.append(my_sample_list[-names-1]) -# print('\n'.join(new_list)) - -for person in range(len(my_sample_list)): - print(my_sample_list[-person-1]) \ No newline at end of file diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index fab02072..8215cf02 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -1,7 +1,3 @@ people = [ 'Lebron','Aaliyah','Diamond','Dominique','Aliyah','Jazmin','Darnell','Hatfield','Hawkins','Hayden','Hayes','Haynes','Hays','Head','Heath','Hebert','Henderson','Hendricks','Hendrix','Henry','Hensley','Henson','Herman','Hernandez','Herrera','Herring','Hess','Hester','Hewitt','Hickman','Hicks','Higgins','Hill','Hines','Hinton','Hobbs','Hodge','Hodges','Hoffman','Hogan','Holcomb','Holden','Holder','Holland','Holloway','Holman','Holmes','Holt','Hood','Hooper','Hoover','Hopkins','Hopper','Horn','Horne','Horton','House','Houston','Howard','Howe','Howell','Hubbard','Huber','Hudson','Huff','Wally','Hughes','Hull','Humphrey','Hunt','Hunter','Hurley','Hurst','Hutchinson','Hyde','Ingram','Irwin','Jackson','Jacobs','Jacobson','James','Jarvis','Jefferson','Jenkins','Jennings','Jensen','Jimenez','Johns','Johnson','Johnston','Jones','Jordan','Joseph','Joyce','Joyner','Juarez','Justice','Kane','Kaufman','Keith','Keller','Kelley','Kelly','Kemp','Kennedy','Kent','Kerr','Key','Kidd','Kim','King','Kinney','Kirby','Kirk','Kirkland','Klein','Kline','Knapp','Knight','Knowles','Knox','Koch','Kramer','Lamb','Lambert','Lancaster','Landry','Lane','Lang','Langley','Lara','Larsen','Larson','Lawrence','Lawson','Le','Leach','Leblanc','Lee','Leon','Leonard','Lester','Levine','Levy','Lewis','Lindsay','Lindsey','Little','Livingston','Lloyd','Logan','Long','Lopez','Lott','Love','Lowe','Lowery','Lucas','Luna','Lynch','Lynn','Lyons','Macdonald','Macias','Mack','Madden','Maddox','Maldonado','Malone','Mann','Manning','Marks','Marquez','Marsh','Marshall','Martin','Martinez','Mason','Massey','Mathews','Mathis','Matthews','Maxwell','May','Mayer','Maynard','Mayo','Mays','Mcbride','Mccall','Mccarthy','Mccarty','Mcclain','Mcclure','Mcconnell','Mccormick','Mccoy','Mccray','Wally','Mcdaniel','Mcdonald','Mcdowell','Mcfadden','Mcfarland','Mcgee','Mcgowan','Mcguire','Mcintosh','Mcintyre','Mckay','Mckee','Mckenzie','Mckinney','Mcknight','Mclaughlin','Mclean','Mcleod','Mcmahon','Mcmillan','Mcneil','Mcpherson','Meadows','Medina','Mejia','Melendez','Melton','Mendez','Mendoza','Mercado','Mercer','Merrill','Merritt','Meyer','Meyers','Michael','Middleton','Miles','Miller','Mills','Miranda','Mitchell','Molina','Monroe','Lucas','Jake','Scott','Amy','Molly','Hannah','Lucas'] #Your code here: - -for person in range(len(people)): - if people[person] == "Wally": - print(person) diff --git a/exercises/02.5-Finding_wally/test.py b/exercises/02.5-Finding_wally/test.py index 524815dc..f3be59b3 100644 --- a/exercises/02.5-Finding_wally/test.py +++ b/exercises/02.5-Finding_wally/test.py @@ -15,8 +15,15 @@ def test_find(): @pytest.mark.it("Use for loop") def test_for_loop(): - captured = buffer.getvalue() f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') content = f.read() assert content.find("for") > 0 + + +@pytest.mark.it("Use if statement") +def test_if(): + + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("if") > 0 \ No newline at end of file diff --git a/exercises/02.6-letter_counter/README.md b/exercises/02.6-letter_counter/README.md index c0e0e327..c847c603 100644 --- a/exercises/02.6-letter_counter/README.md +++ b/exercises/02.6-letter_counter/README.md @@ -9,11 +9,12 @@ I know that's weird, but they are very adamant, We need this asap! #📝Instructions: 1. letters and the values are the number of times it is repeated throughout the string. +```py Example -print(count()); +print(count()) //will print on the console { h: 1, e: 1, l: 2, o: 1 } - +``` 💡Hints: Ignore white spaces in the string. you should lower case all letters to have an accurate count of all letters regardless of casing of the letter. \ No newline at end of file diff --git a/exercises/02.6-letter_counter/app.py b/exercises/02.6-letter_counter/app.py index 201664ba..fec751a7 100644 --- a/exercises/02.6-letter_counter/app.py +++ b/exercises/02.6-letter_counter/app.py @@ -1,12 +1,7 @@ par = "Lorem ipsum dolor sit amet consectetur adipiscing elit Curabitur eget bibendum turpis Curabitur scelerisque eros ultricies venenatis mi at tempor nisl Integer tincidunt accumsan cursus" -#Your code go here: +counts = {} +#your code go here: -count = {} -for i in par: - if i in count: - count[i] += 1 - else: - count[i] = 1 -print(count) +print(counts) diff --git a/exercises/02.6-letter_counter/test.py b/exercises/02.6-letter_counter/test.py index efc3d01d..7f9f9316 100644 --- a/exercises/02.6-letter_counter/test.py +++ b/exercises/02.6-letter_counter/test.py @@ -6,7 +6,20 @@ import app import pytest -@pytest.mark.it() +@pytest.mark.it("Count letter") +def test_count(): + captured = buffer.getvalue() + assert "{'L': 1, 'o': 6, 'r': 14, 'e': 18, 'm': 7, ' ': 24, 'i': 18, 'p': 4, 's': 14, 'u': 14, 'd': 4, 'l': 5, 't': 16, 'a': 8, 'c': 9, 'n': 10, 'g': 3, 'C': 2, 'b': 4, 'q': 1, 'v': 1, 'I': 1}\n" in captured -@pytest.mark.it() \ No newline at end of file + +@pytest.mark.it("Use for loop and if statement") +def test_loop(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("for") > 0 + +def test_if(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("if") > 0 \ No newline at end of file diff --git a/exercises/03-flip_list/app.py b/exercises/03-flip_list/app.py index 3179c62f..0ceca3c0 100644 --- a/exercises/03-flip_list/app.py +++ b/exercises/03-flip_list/app.py @@ -2,8 +2,4 @@ #your code below: - -new_list = [] -for numb in range(len(arr)): - new_list.append(arr[-(numb+1)]) -print(new_list) +print(new_list) \ No newline at end of file diff --git a/exercises/04-mixed_list/app.py b/exercises/04-mixed_list/app.py index 35ebe33f..6d98968e 100644 --- a/exercises/04-mixed_list/app.py +++ b/exercises/04-mixed_list/app.py @@ -2,18 +2,4 @@ # Your code below: -# for i in range(len(mix)): -# if mix[i] == i: -# i += 1 -# print(type(mix[i])) -# items = [] -# for i in range(len(mix)): -# items = mix[i] -# print(type(items)) - -for items in range(len(mix)): - print(type(mix[items])) - - - #ver lo del metodo de test type and len functions \ No newline at end of file diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md index 5a8eaac3..2a360f69 100644 --- a/exercises/04.1-count_on/README.md +++ b/exercises/04.1-count_on/README.md @@ -1,10 +1,12 @@ -# `04.1``Count On` +#`04.1` Count On -As you saw in the last exercise your list can be a mix `types of data` we are going to divide and conquer. +As you saw in the last exercise your list can be a mix +`types of data` we are going to divide and conquer. Would you be so kind to add all the items with data-type object into the hello list? +```py 💡Hint: Here is how to print ALL the items. my_list = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] @@ -12,9 +14,9 @@ my_list = [42, true, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] for i in range(len(mix)): item = mix[i] print(type(item)) +``` - -# Instructions -1. Loop the given array -2. Push the arrays found to an new array called hello +# 📝Instructions: +1. Loop the given list +2. Push the arrays found to an new list called hello 3. Console log the variable hello diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index 4ee3e919..840a2e54 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,3 +1,5 @@ my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] -#your code go here: \ No newline at end of file +#your code go here: + +print(type(my_list[-1])) diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 923ff5be..da258f75 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -3,11 +3,9 @@ def sum_all_values(items): - total = 0 + my = 0 #The magic happens here: - - for i in range(len(items)): - total += items[i] + return total print(sum_all_values(my_sample_list)) \ No newline at end of file diff --git a/exercises/05.1-sum_odd_items/app.py b/exercises/05.1-sum_odd_items/app.py index 2968b487..14562204 100644 --- a/exercises/05.1-sum_odd_items/app.py +++ b/exercises/05.1-sum_odd_items/app.py @@ -2,10 +2,4 @@ #Your code go here: -def sumOdd(items): - aux = 0 - for i in arr: - if i % 2 != 0: - aux += i - return aux -print(sumOdd(arr)) \ No newline at end of file + diff --git a/exercises/06-forEach_loop/app.py b/exercises/06-forEach_loop/app.py index 41fd8c4f..513aad92 100644 --- a/exercises/06-forEach_loop/app.py +++ b/exercises/06-forEach_loop/app.py @@ -3,5 +3,6 @@ for numb in my_list: #the magic go here: - # if numb % 14 == 0: - print(numb) \ No newline at end of file + + print(numb) + \ No newline at end of file diff --git a/exercises/06.1-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py index 7e24a366..a70b66b7 100644 --- a/exercises/06.1-Everything_is_awesome/app.py +++ b/exercises/06.1-Everything_is_awesome/app.py @@ -4,9 +4,6 @@ def my_function(numbers): new_list = [] for numb in numbers: #The magic go here: - # if numb == 0: - # new_list.append("Yahoo") - # elif numb == 1: - # new_list.append(numb) + return new_list print(my_function(my_list)) diff --git a/exercises/06.1-Everything_is_awesome/test.py b/exercises/06.1-Everything_is_awesome/test.py index f582b588..606bdc3d 100644 --- a/exercises/06.1-Everything_is_awesome/test.py +++ b/exercises/06.1-Everything_is_awesome/test.py @@ -17,4 +17,5 @@ def test_conditional(): f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') content = f.read() assert content.find("if") > 0 + assert content.find("elif") > 0 assert content.find("else") > 0 \ No newline at end of file diff --git a/exercises/07-Dowhile_DO_DO/README.md b/exercises/07-Dowhile_DO_DO/README.md index bf0261e5..5c7f0114 100644 --- a/exercises/07-Dowhile_DO_DO/README.md +++ b/exercises/07-Dowhile_DO_DO/README.md @@ -4,8 +4,7 @@ DO DO DO The do{}while(); is another loop example in python is less commonly used but it is a loop ```py // stating value for the loop -let i = 0; - +let i = 0 // the loop will do everything inside of the do code block do { // print out the i value @@ -13,7 +12,7 @@ do { // increase the i value i++ // evaluate the value -} while (i < 5); +} while (i < 5) ``` diff --git a/exercises/08-Delete_element/README.md b/exercises/08-Delete_element/README.md index 2acaf948..c3b7d1c9 100644 --- a/exercises/08-Delete_element/README.md +++ b/exercises/08-Delete_element/README.md @@ -5,4 +5,12 @@ will be to create a new list with all the other people but Daniella. #📝Instructions 1. Please create a deletePerson function that deletes any given person from the list - and returns a new list without that person. \ No newline at end of file + and returns a new list without that person. + + + ```py + Result: + ['juan', 'ana', 'michelle', 'stefany', 'lucy', 'barak'] +['ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak'] +['juan', 'ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak'] +``` \ No newline at end of file diff --git a/exercises/08-Delete_element/app.py b/exercises/08-Delete_element/app.py index e69de29b..2ea862d8 100644 --- a/exercises/08-Delete_element/app.py +++ b/exercises/08-Delete_element/app.py @@ -0,0 +1,17 @@ +people = ['juan','ana','michelle','daniella','stefany','lucy','barak'] + +#Your code go here: +def deletePerson(person_name): + #Your code go here: + filtered_people = [] + for p in people: + if p != person_name: + filtered_people.append(p) + + return filtered_people + +print(deletePerson("daniella")) +print(deletePerson("juan")) +print(deletePerson("emilio")) + + diff --git a/exercises/08-Delete_element/test.py b/exercises/08-Delete_element/test.py index e69de29b..63b4c676 100644 --- a/exercises/08-Delete_element/test.py +++ b/exercises/08-Delete_element/test.py @@ -0,0 +1,23 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Delete person") +def test_even(): + captured = buffer.getvalue() + assert "['juan', 'ana', 'michelle', 'stefany', 'lucy', 'barak']\n['ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak']\n['juan', 'ana', 'michelle', 'daniella', 'stefany', 'lucy', 'barak']\n" in captured + +@pytest.mark.it("Use for loop and if statement") +def test_for_loop(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("for") > 0 + +def test_if(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("if") > 0 \ No newline at end of file diff --git a/exercises/08.1-Merge_list/app.py b/exercises/08.1-Merge_list/app.py index cec90845..883dff97 100644 --- a/exercises/08.1-Merge_list/app.py +++ b/exercises/08.1-Merge_list/app.py @@ -3,12 +3,6 @@ def merge_list(list1, list2): - merge = [] - for i in list1: - i += i - for j in list2: - j += j - merge = list1 + list2 - - return merge + #Your code go here: + print(merge_list(chunk_one, chunk_two)) diff --git a/exercises/08.2-Divide_and_conquer/app.py b/exercises/08.2-Divide_and_conquer/app.py index 62bc97eb..3460be15 100644 --- a/exercises/08.2-Divide_and_conquer/app.py +++ b/exercises/08.2-Divide_and_conquer/app.py @@ -4,14 +4,5 @@ #Your code here: -odd_number = [] -even_number = [] -def merge_two_list(items): - for i in items: - if i % 2 != 0: - odd_number.append(i) - i += i - else: - even_number.append(i) - return odd_number + even_number -print(merge_two_list(list_of_numbers)) \ No newline at end of file +print(merge_two_list(list_of_numbers)) + diff --git a/exercises/09-Max_integer_from_list/app.py b/exercises/09-Max_integer_from_list/app.py index 8702810f..a07a5ea6 100644 --- a/exercises/09-Max_integer_from_list/app.py +++ b/exercises/09-Max_integer_from_list/app.py @@ -3,9 +3,3 @@ #Your code go from here: -max_integer = 0 -for i in my_list: - if i > max_integer: - max_integer = i -print(max_integer) - diff --git a/exercises/09.1-For_loop_min_value/app.py b/exercises/09.1-For_loop_min_value/app.py index 730c76f5..a6f8c057 100644 --- a/exercises/09.1-For_loop_min_value/app.py +++ b/exercises/09.1-For_loop_min_value/app.py @@ -5,10 +5,3 @@ 35,243,371,3251,351223,13231243,734,856,56,53,234342,56,545343] #Your code here: - -number = 999999999 - -for min_numb in my_list: - if min_numb < number: - number = min_numb -print(number) diff --git a/exercises/10-Find_avg/README.md b/exercises/10-Find_avg/README.md index ea7bc0b1..67d1e966 100644 --- a/exercises/10-Find_avg/README.md +++ b/exercises/10-Find_avg/README.md @@ -3,8 +3,8 @@ # 📝Instructions -1. Calculate the average value of all the items in the list and print it on the console. -2. +1. Declare a variable with value 0. +2. Calculate the average value of all the items in the list and print it on the console. # 💡HINT: To print the average, you have to add all the values and divide the result diff --git a/exercises/10-Find_avg/app.py b/exercises/10-Find_avg/app.py index 86149ec8..8b34d1c0 100644 --- a/exercises/10-Find_avg/app.py +++ b/exercises/10-Find_avg/app.py @@ -1,10 +1,8 @@ my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] #Your code here: +total = 0 +for i in my_list: + total += i / len(my_list) +print(total) - -# total = 0 -for val in my_list: -# total += val -# avg = total / len(my_list) -print(avg) diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py index 57eb8b1d..8ba5d016 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -4,6 +4,4 @@ "email": "test@test.com" } #Your code here: -for k, v in contact.items(): - print(k, ":", v) diff --git a/exercises/11-Nested_list/app.py b/exercises/11-Nested_list/app.py index e3fe69f4..467f6ad8 100644 --- a/exercises/11-Nested_list/app.py +++ b/exercises/11-Nested_list/app.py @@ -3,5 +3,4 @@ # Your code go here: -for grades in coordinatesList: - print(grades[1]) + diff --git a/exercises/12.1-more_mapping/app.py b/exercises/12.1-more_mapping/app.py index 2b80373a..073c5a78 100644 --- a/exercises/12.1-more_mapping/app.py +++ b/exercises/12.1-more_mapping/app.py @@ -1,8 +1,5 @@ myNumbers = [23,234,345,4356234,243,43,56,2] +#Your code go here: -def increment_by_one(numbers): - return numbers * 3 - -result = list(map(increment_by_one, myNumbers)) -print(result) \ No newline at end of file +print(new_list) \ No newline at end of file diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index 4c8c393e..fc43835d 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -2,5 +2,4 @@ def prepender(name): return "My name is: " + name -print(list(map(prepender, names))) - +#Your code go here: diff --git a/exercises/12.3-Map_data_types/app.py b/exercises/12.3-Map_data_types/app.py index eb6330b3..18fb50ba 100644 --- a/exercises/12.3-Map_data_types/app.py +++ b/exercises/12.3-Map_data_types/app.py @@ -2,10 +2,7 @@ def type_list(items): - return type(items) - -result = list(map(type_list, list_Strings)) -print(result) - - + return items +new_list = list(map(type_list, list_Strings)) +print(new_list) \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index 7519d32a..808fd3f7 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -13,7 +13,7 @@ def calculateAge(birthDate): age = today.year - birthDate.year - ((today.month, today.day) < (birthDate.month, birthDate.day)) return age -name_list = list(map(lambda x: "Hello my name is " + str(x["name"]) + " and I am " + calculateAge(date(int(x["birthDate"]))) + " years old", people)) +name_list = list(map(lambda x: "Hello my name is " + str(x["name"]) + " and I am " + str(calculateAge(date(int(x["birthDate"])))) + " years old", people)) print(str(name_list)) \ No newline at end of file diff --git a/exercises/12.5-Yes_and_no/app.py b/exercises/12.5-Yes_and_no/app.py index c8947684..980f87d0 100644 --- a/exercises/12.5-Yes_and_no/app.py +++ b/exercises/12.5-Yes_and_no/app.py @@ -1,13 +1,5 @@ theBools = [0,1,0,0,1,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,0,1] - - -def other(numbers): - if numbers == 1: - return "wiki" - else: - return "woko" -result = list(map(other, theBools)) -print(result) +#Your code go here: diff --git a/exercises/12.6-Transformers/app.py b/exercises/12.6-Transformers/app.py index c2da8ccc..46aa74c8 100644 --- a/exercises/12.6-Transformers/app.py +++ b/exercises/12.6-Transformers/app.py @@ -6,11 +6,6 @@ { "name": 'Bobby', "lastName": 'Mc birth' } ] - -def my_function(items): - return items['name'] +' '+items['lastName'] - -transformed_data = list(map(my_function, incomingAJAXData)) -print(transformed_data) +#Your code go here: diff --git a/exercises/13-Filter_list/app.py b/exercises/13-Filter_list/app.py index dd6ccd61..52aeae07 100644 --- a/exercises/13-Filter_list/app.py +++ b/exercises/13-Filter_list/app.py @@ -2,7 +2,6 @@ def filter_function(items): - return items > 10 - + return items % 2 ==0 greater_than = list(filter(filter_function, allNumbers)) print(greater_than) \ No newline at end of file diff --git a/exercises/13.1-Filter_and_list/app.py b/exercises/13.1-Filter_and_list/app.py index 4a4dc67e..ebd27a8c 100644 --- a/exercises/13.1-Filter_and_list/app.py +++ b/exercises/13.1-Filter_and_list/app.py @@ -1,13 +1,7 @@ allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] +#Your code go here: -def persons(names): - if 'R' in names: - return True - else: - return False - -resultingNames = list(filter(persons, allNames)) print(resultingNames) diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py index 80da5200..ad44d6a5 100644 --- a/exercises/13.2-filter_done_tasks/app.py +++ b/exercises/13.2-filter_done_tasks/app.py @@ -11,8 +11,4 @@ ] - -def my_function(items): - return items['done'] -result = list(filter(my_function, tasks)) -print(result) +#Y diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index 1132dd2b..b03996bb 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -6,12 +6,4 @@ 'Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] - -def filteringList(word): - if 'am' in word: - return True - else: - return False - -my_names = list(filter(filteringList, names)) -print(my_names) +#Your code go here: \ No newline at end of file diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md similarity index 100% rename from exercises/13.4-Making_HTML_with_filter_and_map/RAEDME.md rename to exercises/13.4-Making_HTML_with_filter_and_maP/README.md diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py new file mode 100644 index 00000000..83c41dde --- /dev/null +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py @@ -0,0 +1,13 @@ +all_colors = [ + {"label": 'Red', "sexy": True}, + {"label": 'Pink', "sexy": False}, + {"label": 'Orange', "sexy": True}, + {"label": 'Brown', "sexy": False}, + {"label": 'Pink', "sexy": True}, + {"label": 'Violet', "sexy": True}, + {"label": 'Purple', "sexy": False}, +] + +filtere_colors = list(filter(lambda color: color["sexy"],all_colors)) +result = list(map(lambda color: "
  • "+color["label"]+"
  • ", filtere_colors)) +print("
      " + ''.join(result) + "
    ") \ No newline at end of file diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/test.py b/exercises/13.4-Making_HTML_with_filter_and_maP/test.py similarity index 100% rename from exercises/13.4-Making_HTML_with_filter_and_map/test.py rename to exercises/13.4-Making_HTML_with_filter_and_maP/test.py diff --git a/exercises/13.4-Making_HTML_with_filter_and_map/app.py b/exercises/13.4-Making_HTML_with_filter_and_map/app.py deleted file mode 100644 index e69de29b..00000000 From f0081a42cb89d1216ce7c6bcb9eafa15b77487bf Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 15 Sep 2019 01:44:36 +0000 Subject: [PATCH 91/92] pytest --- exercises/03-flip_list/README.md | 4 ++-- exercises/03-flip_list/app.py | 2 -- exercises/04-mixed_list/README.md | 2 +- exercises/04-mixed_list/app.py | 2 -- exercises/04.1-count_on/README.md | 2 +- exercises/04.1-count_on/app.py | 6 +++++- exercises/07-Dowhile_DO_DO/README.md | 2 +- exercises/08-Delete_element/README.md | 2 +- exercises/08-Delete_element/app.py | 12 ++--------- exercises/12-Map_a_list/README.md | 8 +++---- exercises/12-Map_a_list/app.py | 2 +- .../12.2-Map_function_inside_variable/app.py | 6 +++--- exercises/12.4-Map_list_of_objects/README.md | 8 +++---- exercises/12.4-Map_list_of_objects/app.py | 21 ++++++++++--------- exercises/12.4-Map_list_of_objects/test.py | 11 ++++++++-- exercises/12.6-Transformers/README.md | 8 +++---- exercises/13-Filter_list/README.md | 4 ++-- exercises/13.1-Filter_and_list/README.md | 16 +++++++------- exercises/13.1-Filter_and_list/app.py | 7 +++++-- exercises/13.2-filter_done_tasks/README.md | 4 ++-- exercises/13.2-filter_done_tasks/app.py | 3 ++- exercises/13.3-Filter_list_strings/README.md | 7 +++---- exercises/13.3-Filter_list_strings/app.py | 2 +- .../README.md | 4 ++-- .../app.py | 6 +++--- 25 files changed, 77 insertions(+), 74 deletions(-) diff --git a/exercises/03-flip_list/README.md b/exercises/03-flip_list/README.md index bd6003ce..05acafce 100644 --- a/exercises/03-flip_list/README.md +++ b/exercises/03-flip_list/README.md @@ -1,12 +1,12 @@ # `03` Flip list -#📝Instructions: +# 📝Instructions: 1. Create a variable new_list 2. Using a loop, invert the "arr" list. 3. Append the result loop into the new_list variable . 4. With print() function output in the console the result that you have. -```js +```py Initial list: [45, 67, 87, 23, 5, 32, 60] Final list: [60, 32, 5 , 23, 87, 67, 45] ``` diff --git a/exercises/03-flip_list/app.py b/exercises/03-flip_list/app.py index 0ceca3c0..cf1ab123 100644 --- a/exercises/03-flip_list/app.py +++ b/exercises/03-flip_list/app.py @@ -1,5 +1,3 @@ arr = [45, 67, 87, 23, 5, 32, 60] #your code below: - -print(new_list) \ No newline at end of file diff --git a/exercises/04-mixed_list/README.md b/exercises/04-mixed_list/README.md index 6ade569c..4a7835ae 100644 --- a/exercises/04-mixed_list/README.md +++ b/exercises/04-mixed_list/README.md @@ -1,6 +1,6 @@ # `04` Mixed List -#📝instructions: +# 📝instructions: 1. Write a function to programmatically print in the console the types of the values that the list contains in each position 2. You can use the for loop. diff --git a/exercises/04-mixed_list/app.py b/exercises/04-mixed_list/app.py index 6d98968e..4f9e71f4 100644 --- a/exercises/04-mixed_list/app.py +++ b/exercises/04-mixed_list/app.py @@ -1,5 +1,3 @@ mix = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] # Your code below: - - diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md index 2a360f69..2b165734 100644 --- a/exercises/04.1-count_on/README.md +++ b/exercises/04.1-count_on/README.md @@ -1,4 +1,4 @@ -#`04.1` Count On +# `04.1` Count On As you saw in the last exercise your list can be a mix diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index 840a2e54..2dfcfb3f 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,5 +1,9 @@ + my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] #your code go here: +hello = [] +for items in range(len(my_list)) + if my_list[itms] != -print(type(my_list[-1])) +print(hello) diff --git a/exercises/07-Dowhile_DO_DO/README.md b/exercises/07-Dowhile_DO_DO/README.md index 5c7f0114..8d48f90f 100644 --- a/exercises/07-Dowhile_DO_DO/README.md +++ b/exercises/07-Dowhile_DO_DO/README.md @@ -16,7 +16,7 @@ do { ``` -#📝Instructions +# 📝Instructions 1. Print every iteration number on the console from 20 to 0, but `concatenate an exclamation point` to the output if the number is a module of 5 diff --git a/exercises/08-Delete_element/README.md b/exercises/08-Delete_element/README.md index c3b7d1c9..05dac394 100644 --- a/exercises/08-Delete_element/README.md +++ b/exercises/08-Delete_element/README.md @@ -3,7 +3,7 @@ The only way to delete `Daniella` from the list (without cheating) will be to create a new list with all the other people but Daniella. -#📝Instructions +# 📝Instructions 1. Please create a deletePerson function that deletes any given person from the list and returns a new list without that person. diff --git a/exercises/08-Delete_element/app.py b/exercises/08-Delete_element/app.py index 2ea862d8..0538c11b 100644 --- a/exercises/08-Delete_element/app.py +++ b/exercises/08-Delete_element/app.py @@ -3,15 +3,7 @@ #Your code go here: def deletePerson(person_name): #Your code go here: - filtered_people = [] - for p in people: - if p != person_name: - filtered_people.append(p) - - return filtered_people - + print(deletePerson("daniella")) print(deletePerson("juan")) -print(deletePerson("emilio")) - - +print(deletePerson("emilio")) \ No newline at end of file diff --git a/exercises/12-Map_a_list/README.md b/exercises/12-Map_a_list/README.md index b8c5e31f..02e97899 100644 --- a/exercises/12-Map_a_list/README.md +++ b/exercises/12-Map_a_list/README.md @@ -1,4 +1,4 @@ -#`12` Map a list +# `12` Map a list ```py Python map() @@ -6,7 +6,7 @@ Python map() The map() function applies a given function to each item of an iterable (list, tuple etc.) and returns a list of the results. -#The syntax of map() is: +# The syntax of map() is: ```py map(function, iterable, ...) ``` @@ -15,14 +15,14 @@ map(function, iterable, ...) iterable iterable which is to be mapped You can pass more than one iterable to the map() function. -#Return Value from map() +# Return Value from map() The map() function applies a given to function to each item of an iterable and returns a list of the results. The returned value from map() (map object) then can be passed to functions like list() (to create a list), set() (to create a set) and so on. -#📝Instructions: +# 📝Instructions: 1. Using the same logic, add the needed code to convert a list of Celsius values into Fahrenheit inside the map function. diff --git a/exercises/12-Map_a_list/app.py b/exercises/12-Map_a_list/app.py index 49344ce6..97e42073 100644 --- a/exercises/12-Map_a_list/app.py +++ b/exercises/12-Map_a_list/app.py @@ -4,6 +4,6 @@ def fahrenheit_values(x): # the magic go here: - # return x * 9/5 + 32 + return x * 9/5 + 32 result = list(map(fahrenheit_values, Celsius_values)) print(result) diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index fc43835d..3d5d3589 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -1,5 +1,5 @@ names = ['Alice','Bob','Marry','Joe','Hilary','Stevia','Dylan'] -def prepender(name): - return "My name is: " + name -#Your code go here: +# def prepender(name): +# return "My name is: " + name +#Your code go here: \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/README.md b/exercises/12.4-Map_list_of_objects/README.md index 0efdafab..5dabaab4 100644 --- a/exercises/12.4-Map_list_of_objects/README.md +++ b/exercises/12.4-Map_list_of_objects/README.md @@ -1,12 +1,12 @@ -#`12.4` Map list of objects +# `12.4` Map list of objects The most common scenario for the mapping function is for simplifying given lists, for example: - The current algorithm creates a lists with only the names of the people and prints it on the console. -#📝Instructions +# 📝Instructions -1. Please update the mapping function so it creates a list where each item contains the following: +1. At this time the function is printing the names only. +2. Please update the mapping function so it creates a list where each item contains the following: `Hello my name is Joe and I am 13 years old.` diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index 808fd3f7..08261f86 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -1,19 +1,20 @@ +import datetime + + people = [ - { "name": 'Joe', "birthDate": (1986,10,24) }, - { "name": 'Bob', "birthDate": (1975,5,24) }, - { "name": 'Erika', "birthDate": (1989,6,12) }, - { "name": 'Dylan', "birthDate": (1999,12,14) }, - { "name": 'Steve', "birthDate": (2003,4,24) } + { "name": 'Joe', "birthDate": datetime.datetime(1986,10,24) }, + { "name": 'Bob', "birthDate": datetime.datetime(1975,5,24) }, + { "name": 'Erika', "birthDate": datetime.datetime(1989,6,12) }, + { "name": 'Dylan', "birthDate": datetime.datetime(1999,12,14) }, + { "name": 'Steve', "birthDate": datetime.datetime(2003,4,24) } ] -from datetime import date def calculateAge(birthDate): - today = date.today() + today = datetime.date.today() age = today.year - birthDate.year - ((today.month, today.day) < (birthDate.month, birthDate.day)) return age -name_list = list(map(lambda x: "Hello my name is " + str(x["name"]) + " and I am " + str(calculateAge(date(int(x["birthDate"])))) + " years old", people)) - +name_list = list(map(lambda person: person["name"], people)) +print(name_list) -print(str(name_list)) \ No newline at end of file diff --git a/exercises/12.4-Map_list_of_objects/test.py b/exercises/12.4-Map_list_of_objects/test.py index 459fd557..0773e852 100644 --- a/exercises/12.4-Map_list_of_objects/test.py +++ b/exercises/12.4-Map_list_of_objects/test.py @@ -6,8 +6,15 @@ import app import pytest -@pytest.mark.it("") +@pytest.mark.it("Good job!!😎") +def test_output(): + captured = buffer.getvalue() + assert "['Hello my name is Joe and I am 32 years old', 'Hello my name is Bob and I am 44 years old', 'Hello my name is Erika and I am 30 years old', 'Hello my name is Dylan and I am 19 years old', 'Hello my name is Steve and I am 16 years old']\n" in captured -@pytest.mark.it("") \ No newline at end of file +@pytest.mark.it("Using map function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("map") > 0 \ No newline at end of file diff --git a/exercises/12.6-Transformers/README.md b/exercises/12.6-Transformers/README.md index d385997a..eabe75c5 100644 --- a/exercises/12.6-Transformers/README.md +++ b/exercises/12.6-Transformers/README.md @@ -1,9 +1,9 @@ -#`12.6` Transformers +# `12.6` Transformers -#📝Instructions +# 📝Instructions -1. Declare a new variable called transformedData and fill it with a list of -strings containing the full name of each user. +1. Declare a new variable called transformedData +2. Fill the declared variable with a list of strings containing the full name of each user. ```py The expected output diff --git a/exercises/13-Filter_list/README.md b/exercises/13-Filter_list/README.md index c6b610b1..8219cba7 100644 --- a/exercises/13-Filter_list/README.md +++ b/exercises/13-Filter_list/README.md @@ -1,10 +1,10 @@ -#`13` Filter list +# `13` Filter list Another looping function that is available on python is the `filter function`. Its main purpose is to remove elements from the original list and return a new list with the result. The code on the left is filtering the odd numbers from the allNumbers list. -#📝Instructions +# 📝Instructions 1. Please update the filtering function so it filters all the numbers bigger than 10. diff --git a/exercises/13.1-Filter_and_list/README.md b/exercises/13.1-Filter_and_list/README.md index 6c400e89..dc506160 100644 --- a/exercises/13.1-Filter_and_list/README.md +++ b/exercises/13.1-Filter_and_list/README.md @@ -1,24 +1,24 @@ -#`13.1` Filter list +# `13.1` Filter list this is another example using filter list in python -For example, this algorithm filters the allNumbers list and returns +For example, this algorithm filters the all_numbers list and returns a new list with only the odds numbers: ```py -allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] +all_numbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] -def myFunction(numb): +def my_function(numb): return numb % 2 == 0 -oddNumbers = list(filter(myFunction, allNumbers)) -print(oddNumbers) +odd_numbers = list(filter(my_function, all_numbers)) +print(odd_numbers) ``` -#📝Instructions -1. Complete the code to make it fill the resultingNames list with only the names that start with letter R +# 📝Instructions +1. Complete the code to make it fill the resulting_names list with only the names that start with letter R 2. Use the filter function ```py diff --git a/exercises/13.1-Filter_and_list/app.py b/exercises/13.1-Filter_and_list/app.py index ebd27a8c..a8018f5d 100644 --- a/exercises/13.1-Filter_and_list/app.py +++ b/exercises/13.1-Filter_and_list/app.py @@ -1,7 +1,10 @@ -allNames = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] +all_names = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] #Your code go here: -print(resultingNames) +print(resulting_names) + + + diff --git a/exercises/13.2-filter_done_tasks/README.md b/exercises/13.2-filter_done_tasks/README.md index ee049093..3c472ab9 100644 --- a/exercises/13.2-filter_done_tasks/README.md +++ b/exercises/13.2-filter_done_tasks/README.md @@ -1,6 +1,6 @@ -#`13.2` Filter done tasks +# `13.2` Filter done tasks -# Instructions +# 📝Instructions 1. Use the filter function to remove all the undone tasks from the tasks list and print the new list on the console. ```py diff --git a/exercises/13.2-filter_done_tasks/app.py b/exercises/13.2-filter_done_tasks/app.py index ad44d6a5..64bf3925 100644 --- a/exercises/13.2-filter_done_tasks/app.py +++ b/exercises/13.2-filter_done_tasks/app.py @@ -11,4 +11,5 @@ ] -#Y +#Your code go here: + diff --git a/exercises/13.3-Filter_list_strings/README.md b/exercises/13.3-Filter_list_strings/README.md index 3d8415c1..4219ce73 100644 --- a/exercises/13.3-Filter_list_strings/README.md +++ b/exercises/13.3-Filter_list_strings/README.md @@ -1,11 +1,10 @@ -#`13.3` Filter list string +# `13.3` Filter list string -#📝Instructions: +# 📝Instructions: 1. Given a list names please create a function filters the list with only the names that contain the given string. -2. Create a function called filteringList that take two values one is the - list and second one is the filter desire. +2. The given string is `'am'` 3. The search should NOT be Case Sensitive. ```py diff --git a/exercises/13.3-Filter_list_strings/app.py b/exercises/13.3-Filter_list_strings/app.py index b03996bb..b9c6af6b 100644 --- a/exercises/13.3-Filter_list_strings/app.py +++ b/exercises/13.3-Filter_list_strings/app.py @@ -6,4 +6,4 @@ 'Samuel','Grace','Sebastian','Chloe','David','Camila','Carter','Penelope','Wyatt','Riley'] -#Your code go here: \ No newline at end of file +#Your code go here: diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/README.md b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md index b658026c..512f18a8 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/README.md +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md @@ -1,6 +1,6 @@ -#`13.4` Making HTML using filter function and map funtion +#m`13.4` Making HTML using filter function and map funtion -#📝Instructions from your teacher: +# 📝Instructions from your teacher: 1. Fill the generateLI and filterColors function to make the exercise print the following HTML with only the sexy colors: ```py Expexted: diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py index 83c41dde..0276a9f6 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py @@ -8,6 +8,6 @@ {"label": 'Purple', "sexy": False}, ] -filtere_colors = list(filter(lambda color: color["sexy"],all_colors)) -result = list(map(lambda color: "
  • "+color["label"]+"
  • ", filtere_colors)) -print("
      " + ''.join(result) + "
    ") \ No newline at end of file +filter_colors = list(filter(lambda color: color["sexy"],all_colors)) +general_li = list(map(lambda color: "
  • "+color["label"]+"
  • ", filter_colors)) +print("
      " + ''.join(general_li) + "
    ") \ No newline at end of file From 8e95462aa1f753135841c131ae524984f34f2f7c Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sun, 15 Sep 2019 03:18:04 +0000 Subject: [PATCH 92/92] readme --- exercises/01.3-Print-the-last-one/app.py | 2 +- exercises/01.3-Print-the-last-one/test.py | 6 +++--- exercises/01.4-Add-item-to-list/app.py | 2 +- exercises/02-Loop-list/README.md | 6 +++--- exercises/02.1-Loop-from-the-top/README.md | 2 +- exercises/02.4-One_last_looping/README.md | 4 ++-- exercises/02.5-Finding_wally/README.md | 2 +- exercises/02.5-Finding_wally/app.py | 4 ++++ exercises/02.6-letter_counter/README.md | 2 +- exercises/05-Sum_all_items/README.md | 2 +- exercises/05-Sum_all_items/app.py | 2 +- exercises/08.2-Divide_and_conquer/README.md | 2 +- exercises/10-Find_avg/app.py | 4 ---- .../README.md | 9 ++++++--- exercises/11-Nested_list/README.md | 2 +- exercises/12-Map_a_list/app.py | 2 +- .../12.2-Map_function_inside_variable/README.md | 2 +- .../12.2-Map_function_inside_variable/app.py | 4 ++-- exercises/12.3-Map_data_types/README.md | 4 ++-- exercises/12.4-Map_list_of_objects/app.py | 2 +- exercises/12.5-Yes_and_no/README.md | 6 +++--- .../README.md | 4 ++-- .../13.4-Making_HTML_with_filter_and_maP/app.py | 2 ++ exercises/14-Matrix_Builder/README.md | 2 +- exercises/14-Matrix_Builder/app.py | 17 +++-------------- exercises/14.1-Parking_lot_check/README.md | 2 +- exercises/15-Techno_beat/README.md | 4 ++-- 27 files changed, 48 insertions(+), 54 deletions(-) diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index f33009bc..76b74ea6 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -1,5 +1,5 @@ #You have to import random function -import random + def generate_random_list(): aux_list = [] diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index b06bdf6e..551f30e1 100644 --- a/exercises/01.3-Print-the-last-one/test.py +++ b/exercises/01.3-Print-the-last-one/test.py @@ -9,9 +9,9 @@ sys.stdout = buffer = io.StringIO() -@pytest.mark.it("create and assign the value to the variable the_last_one") -def test_create_assign(): - assert app.the_last_one is not None +# @pytest.mark.it("create and assign the value to the variable the_last_one") +# def test_create_assign(): +# assert app.the_last_one is not None # @pytest.mark.it("print in the console the_last_one") diff --git a/exercises/01.4-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py index 440a98e8..9f98be68 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -1,5 +1,5 @@ #Remember import random function here: - +import random my_list = [4,5,734,43,45] diff --git a/exercises/02-Loop-list/README.md b/exercises/02-Loop-list/README.md index b3d6de33..68cac128 100644 --- a/exercises/02-Loop-list/README.md +++ b/exercises/02-Loop-list/README.md @@ -1,8 +1,8 @@ # `02` Loop list -# Instructions from your teacher: -The code right now is printing the first item in the console. -Instead of doing that, print `all the elements` in the list. +# 📝Instructions from your teacher: +1. The code right now is printing the first item in the console. +2. Instead of doing that, print `all the elements` in the list. ```py You will have to loop through the whole array using a for loop. ``` diff --git a/exercises/02.1-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md index 4dda8577..e4d687a7 100644 --- a/exercises/02.1-Loop-from-the-top/README.md +++ b/exercises/02.1-Loop-from-the-top/README.md @@ -4,7 +4,7 @@ This loop is `looping` the list from beginning to end... increasing one by one. ``` # 📝Instructions -Lets try looping from the end to the beginning. +1. Lets try looping from the end to the beginning. The console output should be something like this: ```js diff --git a/exercises/02.4-One_last_looping/README.md b/exercises/02.4-One_last_looping/README.md index c103c829..a728b3b1 100644 --- a/exercises/02.4-One_last_looping/README.md +++ b/exercises/02.4-One_last_looping/README.md @@ -1,6 +1,6 @@ -#`02.4` One last looping +# `02.4` One last looping -#📝Instructions: +# 📝Instructions: 1. Change the second item value to 'Steven' 2. Set the last position to 'Pepe' 3. Set the first element to the value of the 3rd element concatenated to the value of the 5th element. diff --git a/exercises/02.5-Finding_wally/README.md b/exercises/02.5-Finding_wally/README.md index ecc7cfb4..965aa16f 100644 --- a/exercises/02.5-Finding_wally/README.md +++ b/exercises/02.5-Finding_wally/README.md @@ -1,6 +1,6 @@ # `02.5` Finding Wally -#📝Instructions: +# 📝Instructions: 1. Find Wally :) 2. Print the position(s) of Wally in the console. diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index 8215cf02..5ae03d3e 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -1,3 +1,7 @@ people = [ 'Lebron','Aaliyah','Diamond','Dominique','Aliyah','Jazmin','Darnell','Hatfield','Hawkins','Hayden','Hayes','Haynes','Hays','Head','Heath','Hebert','Henderson','Hendricks','Hendrix','Henry','Hensley','Henson','Herman','Hernandez','Herrera','Herring','Hess','Hester','Hewitt','Hickman','Hicks','Higgins','Hill','Hines','Hinton','Hobbs','Hodge','Hodges','Hoffman','Hogan','Holcomb','Holden','Holder','Holland','Holloway','Holman','Holmes','Holt','Hood','Hooper','Hoover','Hopkins','Hopper','Horn','Horne','Horton','House','Houston','Howard','Howe','Howell','Hubbard','Huber','Hudson','Huff','Wally','Hughes','Hull','Humphrey','Hunt','Hunter','Hurley','Hurst','Hutchinson','Hyde','Ingram','Irwin','Jackson','Jacobs','Jacobson','James','Jarvis','Jefferson','Jenkins','Jennings','Jensen','Jimenez','Johns','Johnson','Johnston','Jones','Jordan','Joseph','Joyce','Joyner','Juarez','Justice','Kane','Kaufman','Keith','Keller','Kelley','Kelly','Kemp','Kennedy','Kent','Kerr','Key','Kidd','Kim','King','Kinney','Kirby','Kirk','Kirkland','Klein','Kline','Knapp','Knight','Knowles','Knox','Koch','Kramer','Lamb','Lambert','Lancaster','Landry','Lane','Lang','Langley','Lara','Larsen','Larson','Lawrence','Lawson','Le','Leach','Leblanc','Lee','Leon','Leonard','Lester','Levine','Levy','Lewis','Lindsay','Lindsey','Little','Livingston','Lloyd','Logan','Long','Lopez','Lott','Love','Lowe','Lowery','Lucas','Luna','Lynch','Lynn','Lyons','Macdonald','Macias','Mack','Madden','Maddox','Maldonado','Malone','Mann','Manning','Marks','Marquez','Marsh','Marshall','Martin','Martinez','Mason','Massey','Mathews','Mathis','Matthews','Maxwell','May','Mayer','Maynard','Mayo','Mays','Mcbride','Mccall','Mccarthy','Mccarty','Mcclain','Mcclure','Mcconnell','Mccormick','Mccoy','Mccray','Wally','Mcdaniel','Mcdonald','Mcdowell','Mcfadden','Mcfarland','Mcgee','Mcgowan','Mcguire','Mcintosh','Mcintyre','Mckay','Mckee','Mckenzie','Mckinney','Mcknight','Mclaughlin','Mclean','Mcleod','Mcmahon','Mcmillan','Mcneil','Mcpherson','Meadows','Medina','Mejia','Melendez','Melton','Mendez','Mendoza','Mercado','Mercer','Merrill','Merritt','Meyer','Meyers','Michael','Middleton','Miles','Miller','Mills','Miranda','Mitchell','Molina','Monroe','Lucas','Jake','Scott','Amy','Molly','Hannah','Lucas'] #Your code here: + +for name in range(len(people)): + if people[name] == "Wally": + print(name) \ No newline at end of file diff --git a/exercises/02.6-letter_counter/README.md b/exercises/02.6-letter_counter/README.md index c847c603..db34bc84 100644 --- a/exercises/02.6-letter_counter/README.md +++ b/exercises/02.6-letter_counter/README.md @@ -6,7 +6,7 @@ Our customer needs a program that counts the letters repetitions in a given stri I know that's weird, but they are very adamant, We need this asap! ``` -#📝Instructions: +# 📝Instructions: 1. letters and the values are the number of times it is repeated throughout the string. ```py diff --git a/exercises/05-Sum_all_items/README.md b/exercises/05-Sum_all_items/README.md index c6a987c2..902f2059 100644 --- a/exercises/05-Sum_all_items/README.md +++ b/exercises/05-Sum_all_items/README.md @@ -1,7 +1,7 @@ # `05` Sum all items -#📝Instructions: +# 📝Instructions: 1. Complete the code of the function "sum" so that it returns the sum of all the items in my_sample_list. ```py diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index da258f75..534d4601 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -3,7 +3,7 @@ def sum_all_values(items): - my = 0 + total= 0 #The magic happens here: diff --git a/exercises/08.2-Divide_and_conquer/README.md b/exercises/08.2-Divide_and_conquer/README.md index bb90c422..797bf968 100644 --- a/exercises/08.2-Divide_and_conquer/README.md +++ b/exercises/08.2-Divide_and_conquer/README.md @@ -1,6 +1,6 @@ # `08.2` Divide and conquer: -#📝Instructions +# 📝Instructions 1. Create a function called mergeTwoList that expects an list of numbers (integers). 2. Loop through the list and separate the odd and the even numbers in different lists. 3. If the number is odd number push it to a placeholder list named odd. diff --git a/exercises/10-Find_avg/app.py b/exercises/10-Find_avg/app.py index 8b34d1c0..fe495015 100644 --- a/exercises/10-Find_avg/app.py +++ b/exercises/10-Find_avg/app.py @@ -1,8 +1,4 @@ my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] #Your code here: -total = 0 -for i in my_list: - total += i / len(my_list) -print(total) diff --git a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md index 6887be4e..6a3e1a97 100644 --- a/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md @@ -19,6 +19,9 @@ email : test@nowhere.com ``` 💡Hints --contact.keys() #['fullname', 'phone', 'email'] --contact.values() #['Jane Doe', '321-321-4321', 'test@test.com'] --contact.items() #[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ('email', 'test@test.com')] +-contact.keys() `['fullname', 'phone', 'email']` + +-contact.values() `['Jane Doe', '321-321-4321', 'test@test.com']` + +-contact.items() `[('fullname', 'Jane Doe'), ('phone', '321-321-4321'), ` + `('email', 'test@test.com')]` diff --git a/exercises/11-Nested_list/README.md b/exercises/11-Nested_list/README.md index 8f1b78c9..923239eb 100644 --- a/exercises/11-Nested_list/README.md +++ b/exercises/11-Nested_list/README.md @@ -10,7 +10,7 @@ In this example, we have a list of coordinates that you can access by doing the longitude = coordinatesList[0][1]; -#📝Instructions: +# 📝Instructions: Loop through the list printing only the longitudes. ```py The result should be something like this: diff --git a/exercises/12-Map_a_list/app.py b/exercises/12-Map_a_list/app.py index 97e42073..f0b071cc 100644 --- a/exercises/12-Map_a_list/app.py +++ b/exercises/12-Map_a_list/app.py @@ -4,6 +4,6 @@ def fahrenheit_values(x): # the magic go here: - return x * 9/5 + 32 + result = list(map(fahrenheit_values, Celsius_values)) print(result) diff --git a/exercises/12.2-Map_function_inside_variable/README.md b/exercises/12.2-Map_function_inside_variable/README.md index ea2c056f..f7bbaa3c 100644 --- a/exercises/12.2-Map_function_inside_variable/README.md +++ b/exercises/12.2-Map_function_inside_variable/README.md @@ -5,7 +5,7 @@ The variable names contains a lot of names (dugh...) The function stored in the variable prepender returns whatever is passed to it but prepended with the string: 'My name is:' -#📝Instructions +# 📝Instructions 1. Please map the names list using the prepender function to create a new list that looks like this: diff --git a/exercises/12.2-Map_function_inside_variable/app.py b/exercises/12.2-Map_function_inside_variable/app.py index 3d5d3589..5eb02a38 100644 --- a/exercises/12.2-Map_function_inside_variable/app.py +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -1,5 +1,5 @@ names = ['Alice','Bob','Marry','Joe','Hilary','Stevia','Dylan'] -# def prepender(name): -# return "My name is: " + name +def prepender(name): + return "My name is: " + name #Your code go here: \ No newline at end of file diff --git a/exercises/12.3-Map_data_types/README.md b/exercises/12.3-Map_data_types/README.md index a4952193..edfac384 100644 --- a/exercises/12.3-Map_data_types/README.md +++ b/exercises/12.3-Map_data_types/README.md @@ -1,7 +1,7 @@ -#`12.3` Map data types +# `12.3` Map data types Some times lists come with mixed values and you need to unify them into only one data type. -#📝Instructions +# 📝Instructions Update the map function to make it create a new list that contains the data types of each corresponding item from the original list. diff --git a/exercises/12.4-Map_list_of_objects/app.py b/exercises/12.4-Map_list_of_objects/app.py index 08261f86..8cfea2f9 100644 --- a/exercises/12.4-Map_list_of_objects/app.py +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -15,6 +15,6 @@ def calculateAge(birthDate): age = today.year - birthDate.year - ((today.month, today.day) < (birthDate.month, birthDate.day)) return age -name_list = list(map(lambda person: person["name"], people)) +name_list = list(map(lambda person: person["name"] , people)) print(name_list) diff --git a/exercises/12.5-Yes_and_no/README.md b/exercises/12.5-Yes_and_no/README.md index 6b6830f6..ad18cb70 100644 --- a/exercises/12.5-Yes_and_no/README.md +++ b/exercises/12.5-Yes_and_no/README.md @@ -1,8 +1,8 @@ -#`12.5` Yes and no +# `12.5` Yes and no -#📝Instructions +# 📝Instructions 1. Please use the list map functionality to loop the list of booleans and create a new list - that contains the string 'wiki' for every 1 and 'woko' for every 0 that the original list had. + that contains the string 'wiki' for every 1 and 'woko' for every 0 that the original list had. 2. Print that list on the console. ```py diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/README.md b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md index 512f18a8..15f778e7 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/README.md +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md @@ -1,7 +1,7 @@ -#m`13.4` Making HTML using filter function and map funtion +# `13.4` Making HTML using filter function and map funtion # 📝Instructions from your teacher: -1. Fill the generateLI and filterColors function to make the exercise print the following HTML with only the sexy colors: +1. Fill the generate_li and filter_colors function to make the exercise print the following HTML with only the sexy colors: ```py Expexted:
    • Red
    • Orange
    • Pink
    • Violet
    diff --git a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py index 0276a9f6..7c19e703 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/app.py +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py @@ -8,6 +8,8 @@ {"label": 'Purple', "sexy": False}, ] +#Your code go here: + filter_colors = list(filter(lambda color: color["sexy"],all_colors)) general_li = list(map(lambda color: "
  • "+color["label"]+"
  • ", filter_colors)) print("
      " + ''.join(general_li) + "
    ") \ No newline at end of file diff --git a/exercises/14-Matrix_Builder/README.md b/exercises/14-Matrix_Builder/README.md index fe2248f8..1012745c 100644 --- a/exercises/14-Matrix_Builder/README.md +++ b/exercises/14-Matrix_Builder/README.md @@ -3,7 +3,7 @@ After some malicious code, mainly by Mr. Smith, the matrix has some gaping hole and it needs some help to rebuild. Create a matrix of random 0's, and 1's based on a parameter. -#📝Instructions +# 📝Instructions 1. Create a function called matrixBuilder, which will expect 1 parameter (an integer). This number represents the amount of rows and columns for the matrix. Example: 5 means that the matrix should be 5x5. diff --git a/exercises/14-Matrix_Builder/app.py b/exercises/14-Matrix_Builder/app.py index 58f06fc3..5ddb21f8 100644 --- a/exercises/14-Matrix_Builder/app.py +++ b/exercises/14-Matrix_Builder/app.py @@ -1,16 +1,5 @@ -import random +#Import random + +#Create the function below: -def matrix_function(numbers): - row = [] - for i in range(numbers): - i+=i - columns = [] - for x in range(numbers): - x+=i - columns.append(random.randint(0,1)*1) - row.append(columns) - return row -print(matrix_function(5)) -#this in onle returning the 5 integer numbers into the rows and columns -# have to reviewing this \ No newline at end of file diff --git a/exercises/14.1-Parking_lot_check/README.md b/exercises/14.1-Parking_lot_check/README.md index 38e0159e..44f78f8d 100644 --- a/exercises/14.1-Parking_lot_check/README.md +++ b/exercises/14.1-Parking_lot_check/README.md @@ -1,4 +1,4 @@ -#`14.1` Parking Lot +# `14.1` Parking Lot We can use a 2 dimensional array (matrix) to represent the current state of a parking lot like this: ![Parking lot](https://storage.googleapis.com/replit/images/1558366147943_71c41e2a3f01564b5bdba6618797af79.pn) diff --git a/exercises/15-Techno_beat/README.md b/exercises/15-Techno_beat/README.md index 6907c0bd..582ceb0e 100644 --- a/exercises/15-Techno_beat/README.md +++ b/exercises/15-Techno_beat/README.md @@ -1,7 +1,7 @@ -#`15` Techno Beats +# `15` Techno Beats You are working with a DJ and he needs a program that can create a beats for his songs. -#📝Instructions: +# 📝Instructions: 1. Create a function lyricsGenerator that receives a list The list passed to the function will be something like this: [0,0,1,1,0,0,0] pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy