diff --git a/exercises/00-welcome/README.md b/exercises/00-welcome/README.md new file mode 100644 index 00000000..7c26e75b --- /dev/null +++ b/exercises/00-welcome/README.md @@ -0,0 +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-hello-world/README.md b/exercises/01-hello-world/README.md new file mode 100644 index 00000000..5059286b --- /dev/null +++ b/exercises/01-hello-world/README.md @@ -0,0 +1,20 @@ +# `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".` + +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 +print("How are you?") +``` + +📝 Instructions: + +```md +Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well. +``` + diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py new file mode 100644 index 00000000..6ffb617d --- /dev/null +++ b/exercises/01-hello-world/app.py @@ -0,0 +1,5 @@ + + +#You have to print `hello` in the console, your code go here: +print("Hello World") + diff --git a/exercises/01-hello-world/test.py b/exercises/01-hello-world/test.py new file mode 100644 index 00000000..ca104630 --- /dev/null +++ b/exercises/01-hello-world/test.py @@ -0,0 +1,36 @@ +import io +import sys +import os +sys.stdout = buffer = io.StringIO() + +# 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 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("Output 'Hello World'") +def test_output(): + captured = buffer.getvalue() + 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-welcome/README.md b/exercises/01-welcome/README.md deleted file mode 100644 index 803a35e3..00000000 --- a/exercises/01-welcome/README.md +++ /dev/null @@ -1 +0,0 @@ -# Welcome to Python! \ No newline at end of file diff --git a/exercises/01.1-Access-and-Retrieve/README.md b/exercises/01.1-Access-and-Retrieve/README.md new file mode 100644 index 00000000..676c3e6d --- /dev/null +++ b/exercises/01.1-Access-and-Retrieve/README.md @@ -0,0 +1,31 @@ +# `01.1` 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." + +For example, we could have an array that is storing the days of the week: +```js +my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday']; +``` + +![What is an list?](http://i.imgur.com/DbmSOHT.png) + +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). +The index is an integer value that represents the position in which the element is located. +Protip: Every array starts from cero (0)! +``` + +## 📝 Instructions + +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/01.1-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py new file mode 100644 index 00000000..39ff0606 --- /dev/null +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -0,0 +1,10 @@ + +my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] + +#1. print the item here + +#2. change 'thursday'a value here to None + +#3. print the position of step 2 + + diff --git a/exercises/01.1-Access-and-Retrieve/test.py b/exercises/01.1-Access-and-Retrieve/test.py new file mode 100644 index 00000000..18430bbb --- /dev/null +++ b/exercises/01.1-Access-and-Retrieve/test.py @@ -0,0 +1,22 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_list +import pytest + +@pytest.mark.it('Your console have to print the 3rd item from the `list`') +def test_output_one(): + print(my_list[2]) + captured = buffer.getvalue() + assert "tuesday\n" in captured + +@pytest.mark.it('Your code have to print the position of step 2') +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/01.2-Retrieve-items/README.md b/exercises/01.2-Retrieve-items/README.md new file mode 100644 index 00000000..9e7d9609 --- /dev/null +++ b/exercises/01.2-Retrieve-items/README.md @@ -0,0 +1,13 @@ +# `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. + +You need to `wrap` the index into `brackets` like this: +```js +my_value = list[index]; +``` + +## 📝 Instructions +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/01.2-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py new file mode 100644 index 00000000..d4305d84 --- /dev/null +++ b/exercises/01.2-Retrieve-items/app.py @@ -0,0 +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: + + diff --git a/exercises/01.2-Retrieve-items/test.py b/exercises/01.2-Retrieve-items/test.py new file mode 100644 index 00000000..56a1c265 --- /dev/null +++ b/exercises/01.2-Retrieve-items/test.py @@ -0,0 +1,20 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +from app import my_list +import pytest + + +@pytest.mark.it('You have to print the 1st element of the list') +def test_output_one(): + print(my_list[0]) + captured = buffer.getvalue() + assert "4\n" in captured + +@pytest.mark.it('You have to print the 4th element of the list') +def test_output_fourd(): + print(my_list[3]) + captured = buffer.getvalue() + assert "43\n" in captured + diff --git a/exercises/01.3-Print-the-last-one/README.md b/exercises/01.3-Print-the-last-one/README.md new file mode 100644 index 00000000..1d38c7cf --- /dev/null +++ b/exercises/01.3-Print-the-last-one/README.md @@ -0,0 +1,21 @@ +# `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. + +You know that the property: +```py +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. + + +💡Hint: +```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/app.py b/exercises/01.3-Print-the-last-one/app.py new file mode 100644 index 00000000..76b74ea6 --- /dev/null +++ b/exercises/01.3-Print-the-last-one/app.py @@ -0,0 +1,14 @@ +#You have to import random function + + +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() + +#Feel happy to write the code below, good luck: diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py new file mode 100644 index 00000000..551f30e1 --- /dev/null +++ b/exercises/01.3-Print-the-last-one/test.py @@ -0,0 +1,26 @@ +import io +import sys +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") +# 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("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/README.md b/exercises/01.4-Add-item-to-list/README.md new file mode 100644 index 00000000..997888e1 --- /dev/null +++ b/exercises/01.4-Add-item-to-list/README.md @@ -0,0 +1,16 @@ +# `01.4` Add items to the list + +# 📝Instructions +1. Add 10 random integers to the "arr" list. + + +💡Tips: +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: + +```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/01.4-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py new file mode 100644 index 00000000..9f98be68 --- /dev/null +++ b/exercises/01.4-Add-item-to-list/app.py @@ -0,0 +1,10 @@ +#Remember import random function here: +import random + +my_list = [4,5,734,43,45] + +#The magic is here: + + + +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 new file mode 100644 index 00000000..20bf728b --- /dev/null +++ b/exercises/01.4-Add-item-to-list/test.py @@ -0,0 +1,24 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +import pytest +import app +import os +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, 100)) is not None + +@pytest.mark.it("Output of the list with 15 items numbers") +def test_output(): + captured = buffer.getvalue() + 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/README.md b/exercises/01.5-loop-seventeen/README.md new file mode 100644 index 00000000..2f57e907 --- /dev/null +++ b/exercises/01.5-loop-seventeen/README.md @@ -0,0 +1,31 @@ +# `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. + + + +💡HINT: +1. This how you loop +`https://www.w3schools.com/python/python_for_loops.asp` + +Expected console result: +```py +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/01.5-loop-seventeen/app.py b/exercises/01.5-loop-seventeen/app.py new file mode 100644 index 00000000..38e47b7d --- /dev/null +++ b/exercises/01.5-loop-seventeen/app.py @@ -0,0 +1 @@ +#Your code here, have fun: diff --git a/exercises/01.5-loop-seventeen/test.py b/exercises/01.5-loop-seventeen/test.py new file mode 100644 index 00000000..f21c6053 --- /dev/null +++ b/exercises/01.5-loop-seventeen/test.py @@ -0,0 +1,22 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + + +import os +import pytest +import app + +@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 you 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 diff --git a/exercises/02-Loop-list/README.md b/exercises/02-Loop-list/README.md new file mode 100644 index 00000000..68cac128 --- /dev/null +++ b/exercises/02-Loop-list/README.md @@ -0,0 +1,38 @@ +# `02` Loop 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. +``` + +💡HINT +1. Remember that to access the value of a position you have to use the index +2. print(my_list[index]); + +Expected console result: +```py +232 +32 +1 +4 +55 +4 +3 +32 +3 +24 +5 +5 +5 +34 +2 +3 +5 +5365743 +52 +34 +3 +55 +``` \ No newline at end of file diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py new file mode 100644 index 00000000..b2ab27c2 --- /dev/null +++ b/exercises/02-Loop-list/app.py @@ -0,0 +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] + +#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 new file mode 100644 index 00000000..3039a498 --- /dev/null +++ b/exercises/02-Loop-list/test.py @@ -0,0 +1,21 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + + + +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\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(): + + 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-hello-world/README.md b/exercises/02-hello-world/README.md deleted file mode 100644 index 5273e055..00000000 --- a/exercises/02-hello-world/README.md +++ /dev/null @@ -1,20 +0,0 @@ -# `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". - -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 -print("How are you?") -``` - -📝 Instructions: - -```md -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 deleted file mode 100644 index 809f9002..00000000 --- a/exercises/02-hello-world/app.py +++ /dev/null @@ -1,5 +0,0 @@ -print("hello") - -def my_function(): - print("Hello Inside Function") - return True diff --git a/exercises/02-hello-world/test.py b/exercises/02-hello-world/test.py deleted file mode 100644 index 4f94ffb0..00000000 --- a/exercises/02-hello-world/test.py +++ /dev/null @@ -1,21 +0,0 @@ -import io -import sys -sys.stdout = buffer = io.StringIO() - -from app import my_function -import pytest - -@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 return True') -def test_for_function_return(capsys): - assert my_function() == True diff --git a/exercises/02.1-Loop-from-the-top/README.md b/exercises/02.1-Loop-from-the-top/README.md new file mode 100644 index 00000000..e4d687a7 --- /dev/null +++ b/exercises/02.1-Loop-from-the-top/README.md @@ -0,0 +1,25 @@ +# `02.1` Loop from the top +```js +This loop is `looping` the list from beginning to end... increasing one by one. +``` + +# 📝Instructions +1. Lets try looping from the end to the beginning. + +The console output should be something like this: +```js +12 +25 +23 +55 +56432 +48 +23 +867543 +8 +654 +47889 +4 +5 +3423 +``` \ No newline at end of file diff --git a/exercises/02.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py new file mode 100644 index 00000000..2b4e6a31 --- /dev/null +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -0,0 +1,7 @@ +my_sample_list = [3423,5,4,47889,654,8,867543,23,48,56432,55,23,25,12] + +#The magic pass below: + + + + diff --git a/exercises/02.1-Loop-from-the-top/test.py b/exercises/02.1-Loop-from-the-top/test.py new file mode 100644 index 00000000..adf93e4f --- /dev/null +++ b/exercises/02.1-Loop-from-the-top/test.py @@ -0,0 +1,21 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +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 new file mode 100644 index 00000000..2aec301b --- /dev/null +++ b/exercises/02.2-Loop-adding-two/README.md @@ -0,0 +1,19 @@ +# `02.2` Loop adding two + +```py +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/02.2-Loop-adding-two/app.py b/exercises/02.2-Loop-adding-two/app.py new file mode 100644 index 00000000..a335d15b --- /dev/null +++ b/exercises/02.2-Loop-adding-two/app.py @@ -0,0 +1,8 @@ +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: + + +for i in range(0, len(my_sample_list), 1): + print(my_sample_list[i]) + diff --git a/exercises/02.2-Loop-adding-two/test.py b/exercises/02.2-Loop-adding-two/test.py new file mode 100644 index 00000000..9a4b8f78 --- /dev/null +++ b/exercises/02.2-Loop-adding-two/test.py @@ -0,0 +1,23 @@ +import io +import sys +sys.stdout = buffer = io.StringIO() + +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 new file mode 100644 index 00000000..727e3bea --- /dev/null +++ b/exercises/02.3-loop-from-the-half-to-the-end/README.md @@ -0,0 +1,21 @@ + +# `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 +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: + +```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 new file mode 100644 index 00000000..b54d88af --- /dev/null +++ b/exercises/02.3-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]) 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 new file mode 100644 index 00000000..7d453319 --- /dev/null +++ b/exercises/02.3-loop-from-the-half-to-the-end/test.py @@ -0,0 +1,21 @@ +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 new file mode 100644 index 00000000..a728b3b1 --- /dev/null +++ b/exercises/02.4-One_last_looping/README.md @@ -0,0 +1,25 @@ +# `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 list and print all the elements. + +💡HINT: +-Remember that list start at position 0. + +The result should be something like this: +```py +Pepe +Bart +Cesco +Fernando +Lou +Maria +Pedro +Lebron +Ruth +Steven +RuthPedro +``` \ No newline at end of file diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py new file mode 100644 index 00000000..c2d1a72c --- /dev/null +++ b/exercises/02.4-One_last_looping/app.py @@ -0,0 +1,3 @@ +my_sample_list = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie'] + +#Your code here: diff --git a/exercises/02.4-One_last_looping/test.py b/exercises/02.4-One_last_looping/test.py new file mode 100644 index 00000000..3006fd91 --- /dev/null +++ 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 diff --git a/exercises/02.5-Finding_wally/README.md b/exercises/02.5-Finding_wally/README.md new file mode 100644 index 00000000..965aa16f --- /dev/null +++ b/exercises/02.5-Finding_wally/README.md @@ -0,0 +1,19 @@ +# `02.5` Finding Wally + +# 📝Instructions: +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/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py new file mode 100644 index 00000000..5ae03d3e --- /dev/null +++ b/exercises/02.5-Finding_wally/app.py @@ -0,0 +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.5-Finding_wally/test.py b/exercises/02.5-Finding_wally/test.py new file mode 100644 index 00000000..f3be59b3 --- /dev/null +++ b/exercises/02.5-Finding_wally/test.py @@ -0,0 +1,29 @@ +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(): + + 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 new file mode 100644 index 00000000..db34bc84 --- /dev/null +++ b/exercises/02.6-letter_counter/README.md @@ -0,0 +1,20 @@ +# `02.6` Letter counter + +```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: +1. letters and the values are the number of times it is repeated throughout the string. + +```py +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/02.6-letter_counter/app.py b/exercises/02.6-letter_counter/app.py new file mode 100644 index 00000000..fec751a7 --- /dev/null +++ b/exercises/02.6-letter_counter/app.py @@ -0,0 +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" + +counts = {} +#your code go here: + +print(counts) + diff --git a/exercises/02.6-letter_counter/test.py b/exercises/02.6-letter_counter/test.py new file mode 100644 index 00000000..7f9f9316 --- /dev/null +++ b/exercises/02.6-letter_counter/test.py @@ -0,0 +1,25 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@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("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/README.md b/exercises/03-flip_list/README.md new file mode 100644 index 00000000..05acafce --- /dev/null +++ b/exercises/03-flip_list/README.md @@ -0,0 +1,16 @@ +# `03` Flip list + +# 📝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. + +```py +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/03-flip_list/app.py b/exercises/03-flip_list/app.py new file mode 100644 index 00000000..cf1ab123 --- /dev/null +++ b/exercises/03-flip_list/app.py @@ -0,0 +1,3 @@ +arr = [45, 67, 87, 23, 5, 32, 60] + +#your code below: diff --git a/exercises/03-flip_list/test.py b/exercises/03-flip_list/test.py new file mode 100644 index 00000000..467123f0 --- /dev/null +++ b/exercises/03-flip_list/test.py @@ -0,0 +1,33 @@ +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(): + 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") +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 diff --git a/exercises/04-mixed_list/README.md b/exercises/04-mixed_list/README.md new file mode 100644 index 00000000..4a7835ae --- /dev/null +++ b/exercises/04-mixed_list/README.md @@ -0,0 +1,23 @@ +# `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 +2. You can use the for loop. + +```py +The console must have something like this: + + + + + + + + + +``` + +💡Hint: +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 new file mode 100644 index 00000000..4f9e71f4 --- /dev/null +++ b/exercises/04-mixed_list/app.py @@ -0,0 +1,3 @@ +mix = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] + +# Your code below: diff --git a/exercises/04-mixed_list/test.py b/exercises/04-mixed_list/test.py new file mode 100644 index 00000000..c28fa93a --- /dev/null +++ b/exercises/04-mixed_list/test.py @@ -0,0 +1,31 @@ +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 + +@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 diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md new file mode 100644 index 00000000..2b165734 --- /dev/null +++ b/exercises/04.1-count_on/README.md @@ -0,0 +1,22 @@ +# `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? + +```py +💡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 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 new file mode 100644 index 00000000..2dfcfb3f --- /dev/null +++ b/exercises/04.1-count_on/app.py @@ -0,0 +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(hello) diff --git a/exercises/04.1-count_on/test.py b/exercises/04.1-count_on/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/05-Sum_all_items/README.md b/exercises/05-Sum_all_items/README.md new file mode 100644 index 00000000..902f2059 --- /dev/null +++ b/exercises/05-Sum_all_items/README.md @@ -0,0 +1,12 @@ + +# `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. +```py +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/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py new file mode 100644 index 00000000..534d4601 --- /dev/null +++ b/exercises/05-Sum_all_items/app.py @@ -0,0 +1,11 @@ +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: + + + return total +print(sum_all_values(my_sample_list)) \ No newline at end of file diff --git a/exercises/05-Sum_all_items/test.py b/exercises/05-Sum_all_items/test.py new file mode 100644 index 00000000..723a4e77 --- /dev/null +++ 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 new file mode 100644 index 00000000..ade38b64 --- /dev/null +++ b/exercises/05.1-sum_odd_items/README.md @@ -0,0 +1,20 @@ +# `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" variable. +2. Returns and print the result. + +# To do this exercise consider: + +- You will need to `declare an auxiliar variable outside the loop` to keep adding the values. +- 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 +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/app.py b/exercises/05.1-sum_odd_items/app.py new file mode 100644 index 00000000..14562204 --- /dev/null +++ b/exercises/05.1-sum_odd_items/app.py @@ -0,0 +1,5 @@ +arr = [4,5,734,43,45,100,4,56,23,67,23,58,45] + +#Your code go here: + + diff --git a/exercises/05.1-sum_odd_items/test.py b/exercises/05.1-sum_odd_items/test.py new file mode 100644 index 00000000..57a32b3d --- /dev/null +++ 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 new file mode 100644 index 00000000..542e45ac --- /dev/null +++ b/exercises/06-forEach_loop/README.md @@ -0,0 +1,14 @@ +# `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`. + +💡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 new file mode 100644 index 00000000..513aad92 --- /dev/null +++ b/exercises/06-forEach_loop/app.py @@ -0,0 +1,8 @@ +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/06-forEach_loop/test.py b/exercises/06-forEach_loop/test.py new file mode 100644 index 00000000..33637450 --- /dev/null +++ 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 new file mode 100644 index 00000000..6aa75c36 --- /dev/null +++ b/exercises/06.1-Everything_is_awesome/README.md @@ -0,0 +1,16 @@ +# `06.1` Everything is Awesome + +# 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/06.1-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py new file mode 100644 index 00000000..a70b66b7 --- /dev/null +++ b/exercises/06.1-Everything_is_awesome/app.py @@ -0,0 +1,9 @@ +my_list = [ 1, 0, 0, 0, 1, 0, 0, 0, 1, 1 ] + +def my_function(numbers): + new_list = [] + for numb in numbers: + #The magic go here: + + 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 new file mode 100644 index 00000000..606bdc3d --- /dev/null +++ b/exercises/06.1-Everything_is_awesome/test.py @@ -0,0 +1,21 @@ +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("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 new file mode 100644 index 00000000..8d48f90f --- /dev/null +++ b/exercises/07-Dowhile_DO_DO/README.md @@ -0,0 +1,41 @@ +# `07` D0 While + +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 +// 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" + +```py +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/07-Dowhile_DO_DO/app.py b/exercises/07-Dowhile_DO_DO/app.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/07-Dowhile_DO_DO/test.py b/exercises/07-Dowhile_DO_DO/test.py new file mode 100644 index 00000000..e69de29b diff --git a/exercises/08-Delete_element/README.md b/exercises/08-Delete_element/README.md new file mode 100644 index 00000000..05dac394 --- /dev/null +++ b/exercises/08-Delete_element/README.md @@ -0,0 +1,16 @@ +# `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 +1. Please create a deletePerson function that deletes any given person from the list + 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 new file mode 100644 index 00000000..0538c11b --- /dev/null +++ b/exercises/08-Delete_element/app.py @@ -0,0 +1,9 @@ +people = ['juan','ana','michelle','daniella','stefany','lucy','barak'] + +#Your code go here: +def deletePerson(person_name): + #Your code go here: + +print(deletePerson("daniella")) +print(deletePerson("juan")) +print(deletePerson("emilio")) \ No newline at end of file diff --git a/exercises/08-Delete_element/test.py b/exercises/08-Delete_element/test.py new file mode 100644 index 00000000..63b4c676 --- /dev/null +++ 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/README.md b/exercises/08.1-Merge_list/README.md new file mode 100644 index 00000000..8f9c0b60 --- /dev/null +++ b/exercises/08.1-Merge_list/README.md @@ -0,0 +1,19 @@ +# `08.1` Merge List: + +Since we live in a new world, there should be no colors or labels, right? + +# 📝Instructions +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 new file mode 100644 index 00000000..883dff97 --- /dev/null +++ b/exercises/08.1-Merge_list/app.py @@ -0,0 +1,8 @@ +chunk_one = [ 'Lebron', 'Aaliyah', 'Diamond', 'Dominique', 'Aliyah', 'Jazmin', 'Darnell' ] +chunk_two = [ 'Lucas' , 'Jake','Scott','Amy', 'Molly','Hannah','Lucas'] + + +def merge_list(list1, list2): + #Your code go here: + +print(merge_list(chunk_one, chunk_two)) diff --git a/exercises/08.1-Merge_list/test.py b/exercises/08.1-Merge_list/test.py new file mode 100644 index 00000000..b154aeef --- /dev/null +++ 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 new file mode 100644 index 00000000..797bf968 --- /dev/null +++ b/exercises/08.2-Divide_and_conquer/README.md @@ -0,0 +1,18 @@ +# `08.2` Divide and conquer: + +# 📝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. + +```py +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/08.2-Divide_and_conquer/app.py b/exercises/08.2-Divide_and_conquer/app.py new file mode 100644 index 00000000..3460be15 --- /dev/null +++ b/exercises/08.2-Divide_and_conquer/app.py @@ -0,0 +1,8 @@ +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: + + +print(merge_two_list(list_of_numbers)) + diff --git a/exercises/08.2-Divide_and_conquer/test.py b/exercises/08.2-Divide_and_conquer/test.py new file mode 100644 index 00000000..f06bd9af --- /dev/null +++ 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 diff --git a/exercises/09-Max_integer_from_list/README.md b/exercises/09-Max_integer_from_list/README.md new file mode 100644 index 00000000..30421a4c --- /dev/null +++ b/exercises/09-Max_integer_from_list/README.md @@ -0,0 +1,16 @@ +# `09` Max integer from my_list + + +# 📝Instruccions +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. + + ```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 new file mode 100644 index 00000000..a07a5ea6 --- /dev/null +++ b/exercises/09-Max_integer_from_list/app.py @@ -0,0 +1,5 @@ +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 go from here: + diff --git a/exercises/09-Max_integer_from_list/test.py b/exercises/09-Max_integer_from_list/test.py new file mode 100644 index 00000000..0fe7aa04 --- /dev/null +++ b/exercises/09-Max_integer_from_list/test.py @@ -0,0 +1,22 @@ +import io +import os +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 + +@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 new file mode 100644 index 00000000..6d65392d --- /dev/null +++ b/exercises/09.1-For_loop_min_value/README.md @@ -0,0 +1,20 @@ +# `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. + + +# 📝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. + +```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 new file mode 100644 index 00000000..a6f8c057 --- /dev/null +++ b/exercises/09.1-For_loop_min_value/app.py @@ -0,0 +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] + +#Your code here: diff --git a/exercises/09.1-For_loop_min_value/test.py b/exercises/09.1-For_loop_min_value/test.py new file mode 100644 index 00000000..5a1304dc --- /dev/null +++ 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 diff --git a/exercises/10-Find_avg/README.md b/exercises/10-Find_avg/README.md new file mode 100644 index 00000000..67d1e966 --- /dev/null +++ b/exercises/10-Find_avg/README.md @@ -0,0 +1,16 @@ +# `10` Find average + + + +# 📝Instructions +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 +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 new file mode 100644 index 00000000..fe495015 --- /dev/null +++ b/exercises/10-Find_avg/app.py @@ -0,0 +1,4 @@ +my_list = [2323,4344,2325,324413,21234,24531,2123,42234,544,456,345,42,5445,23,5656,423] + +#Your code here: + diff --git a/exercises/10-Find_avg/test.py b/exercises/10-Find_avg/test.py new file mode 100644 index 00000000..53c47d68 --- /dev/null +++ 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 new file mode 100644 index 00000000..6a3e1a97 --- /dev/null +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/README.md @@ -0,0 +1,27 @@ +# `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 +Example console output: +fullname : John Doe +phone : 123-123-2134 +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')]` 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..8ba5d016 --- /dev/null +++ b/exercises/10.1-And_One_and_a_Two_and_a_Three/app.py @@ -0,0 +1,7 @@ +contact = { + "fullname": "Jane Doe", + "phone": "321-321-4321", + "email": "test@test.com" +} +#Your code here: + 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..6c3f02cf --- /dev/null +++ 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 new file mode 100644 index 00000000..923239eb --- /dev/null +++ b/exercises/11-Nested_list/README.md @@ -0,0 +1,24 @@ + +# `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 = coordinatesList[0][1]; + + +# 📝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 new file mode 100644 index 00000000..467f6ad8 --- /dev/null +++ b/exercises/11-Nested_list/app.py @@ -0,0 +1,6 @@ + +coordinatesList = [[33.747252,-112.633853],[-33.867886, -63.987],[41.303921, -81.901693],[-33.350534, -71.653268]] + +# Your code go here: + + diff --git a/exercises/11-Nested_list/test.py b/exercises/11-Nested_list/test.py new file mode 100644 index 00000000..8f044e92 --- /dev/null +++ b/exercises/11-Nested_list/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 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_a_list/README.md b/exercises/12-Map_a_list/README.md new file mode 100644 index 00000000..02e97899 --- /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_a_list/app.py b/exercises/12-Map_a_list/app.py new file mode 100644 index 00000000..f0b071cc --- /dev/null +++ b/exercises/12-Map_a_list/app.py @@ -0,0 +1,9 @@ +Celsius_values = [-2,34,56,-10] + + + +def fahrenheit_values(x): +# the magic go here: + +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.1-more_mapping/README.md b/exercises/12.1-more_mapping/README.md new file mode 100644 index 00000000..26b8afc4 --- /dev/null +++ b/exercises/12.1-more_mapping/README.md @@ -0,0 +1,29 @@ +# `12.1` More mapping + + + +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 +} + +my_list = [1, 2, 3, 4] +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.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. +Remember that your function must return each of the new items to be stored into the new list. + + diff --git a/exercises/12.1-more_mapping/app.py b/exercises/12.1-more_mapping/app.py new file mode 100644 index 00000000..073c5a78 --- /dev/null +++ b/exercises/12.1-more_mapping/app.py @@ -0,0 +1,5 @@ +myNumbers = [23,234,345,4356234,243,43,56,2] + +#Your code go here: + +print(new_list) \ No newline at end of file diff --git a/exercises/12.1-more_mapping/test.py b/exercises/12.1-more_mapping/test.py new file mode 100644 index 00000000..be45cd14 --- /dev/null +++ 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 new file mode 100644 index 00000000..f7bbaa3c --- /dev/null +++ b/exercises/12.2-Map_function_inside_variable/README.md @@ -0,0 +1,13 @@ +# `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) + 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..5eb02a38 --- /dev/null +++ b/exercises/12.2-Map_function_inside_variable/app.py @@ -0,0 +1,5 @@ +names = ['Alice','Bob','Marry','Joe','Hilary','Stevia','Dylan'] + +def prepender(name): + return "My name is: " + name +#Your code go here: \ 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 new file mode 100644 index 00000000..a1fa2361 --- /dev/null +++ b/exercises/12.2-Map_function_inside_variable/test.py @@ -0,0 +1,16 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@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 new file mode 100644 index 00000000..edfac384 --- /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 +[, , , , , , , ] +``` + +💡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..18fb50ba --- /dev/null +++ b/exercises/12.3-Map_data_types/app.py @@ -0,0 +1,8 @@ +list_Strings = ['1','5','45','34','343','34',6556,323] + + +def type_list(items): + return items + +new_list = list(map(type_list, list_Strings)) +print(new_list) \ No newline at end of file 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..4f3b7f1b --- /dev/null +++ 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 new file mode 100644 index 00000000..5dabaab4 --- /dev/null +++ b/exercises/12.4-Map_list_of_objects/README.md @@ -0,0 +1,25 @@ +# `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. 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.` + +💡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: +```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 new file mode 100644 index 00000000..8cfea2f9 --- /dev/null +++ b/exercises/12.4-Map_list_of_objects/app.py @@ -0,0 +1,20 @@ +import datetime + + +people = [ + { "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) } +] + + +def calculateAge(birthDate): + today = datetime.date.today() + age = today.year - birthDate.year - ((today.month, today.day) < (birthDate.month, birthDate.day)) + return age + +name_list = list(map(lambda person: person["name"] , people)) +print(name_list) + 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..0773e852 --- /dev/null +++ b/exercises/12.4-Map_list_of_objects/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!!😎") +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("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.5-Yes_and_no/README.md b/exercises/12.5-Yes_and_no/README.md new file mode 100644 index 00000000..ad18cb70 --- /dev/null +++ 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 new file mode 100644 index 00000000..980f87d0 --- /dev/null +++ b/exercises/12.5-Yes_and_no/app.py @@ -0,0 +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] + +#Your code go here: + + 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..327f60c3 --- /dev/null +++ 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 new file mode 100644 index 00000000..eabe75c5 --- /dev/null +++ b/exercises/12.6-Transformers/README.md @@ -0,0 +1,12 @@ +# `12.6` Transformers + +# 📝Instructions + +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 + +'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 new file mode 100644 index 00000000..46aa74c8 --- /dev/null +++ b/exercises/12.6-Transformers/app.py @@ -0,0 +1,11 @@ +incomingAJAXData = [ + { "name": 'Mario', "lastName": 'Montes' }, + { "name": 'Joe', "lastName": 'Biden' }, + { "name": 'Bill', "lastName": 'Clon' }, + { "name": 'Hilary', "lastName": 'Mccafee' }, + { "name": 'Bobby', "lastName": 'Mc birth' } +] + +#Your code go here: + + diff --git a/exercises/12.6-Transformers/test.py b/exercises/12.6-Transformers/test.py new file mode 100644 index 00000000..e7400264 --- /dev/null +++ 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 diff --git a/exercises/13-Filter_list/README.md b/exercises/13-Filter_list/README.md new file mode 100644 index 00000000..8219cba7 --- /dev/null +++ b/exercises/13-Filter_list/README.md @@ -0,0 +1,15 @@ +# `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-Filter_list/app.py b/exercises/13-Filter_list/app.py new file mode 100644 index 00000000..52aeae07 --- /dev/null +++ b/exercises/13-Filter_list/app.py @@ -0,0 +1,7 @@ +allNumbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] + + +def filter_function(items): + 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-Filter_list/test.py b/exercises/13-Filter_list/test.py new file mode 100644 index 00000000..e3bb2c0f --- /dev/null +++ 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 new file mode 100644 index 00000000..dc506160 --- /dev/null +++ b/exercises/13.1-Filter_and_list/README.md @@ -0,0 +1,27 @@ +# `13.1` Filter list + +this is another example using filter list in python + +For example, this algorithm filters the all_numbers list and returns + a new list with only the odds numbers: + +```py +all_numbers = [23,12,35,5,3,2,3,54,3,21,534,23,42,1] + +def my_function(numb): + return numb % 2 == 0 + +odd_numbers = list(filter(my_function, all_numbers)) +print(odd_numbers) +``` + + + +# 📝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 +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 new file mode 100644 index 00000000..a8018f5d --- /dev/null +++ b/exercises/13.1-Filter_and_list/app.py @@ -0,0 +1,10 @@ + +all_names = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] + +#Your code go here: + +print(resulting_names) + + + + diff --git a/exercises/13.1-Filter_and_list/test.py b/exercises/13.1-Filter_and_list/test.py new file mode 100644 index 00000000..0f67a6c3 --- /dev/null +++ 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 new file mode 100644 index 00000000..3c472ab9 --- /dev/null +++ b/exercises/13.2-filter_done_tasks/README.md @@ -0,0 +1,10 @@ +# `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..64bf3925 --- /dev/null +++ b/exercises/13.2-filter_done_tasks/app.py @@ -0,0 +1,15 @@ + +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 } +] + + +#Your code go here: + 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..b7c11491 --- /dev/null +++ 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 new file mode 100644 index 00000000..4219ce73 --- /dev/null +++ b/exercises/13.3-Filter_list_strings/README.md @@ -0,0 +1,13 @@ +# `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. The given string is `'am'` +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 new file mode 100644 index 00000000..b9c6af6b --- /dev/null +++ b/exercises/13.3-Filter_list_strings/app.py @@ -0,0 +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'] + + +#Your code go here: 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..0efce2a7 --- /dev/null +++ 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 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 new file mode 100644 index 00000000..15f778e7 --- /dev/null +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/README.md @@ -0,0 +1,8 @@ +# `13.4` Making HTML using filter function and map funtion + +# 📝Instructions from your teacher: +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
+``` \ 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..7c19e703 --- /dev/null +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/app.py @@ -0,0 +1,15 @@ +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}, +] + +#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/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-Matrix_Builder/README.md b/exercises/14-Matrix_Builder/README.md new file mode 100644 index 00000000..1012745c --- /dev/null +++ b/exercises/14-Matrix_Builder/README.md @@ -0,0 +1,20 @@ +# `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: +```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 new file mode 100644 index 00000000..5ddb21f8 --- /dev/null +++ b/exercises/14-Matrix_Builder/app.py @@ -0,0 +1,5 @@ +#Import random + +#Create the function below: + + diff --git a/exercises/14-Matrix_Builder/test.py b/exercises/14-Matrix_Builder/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..44f78f8d --- /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 diff --git a/exercises/15-Techno_beat/README.md b/exercises/15-Techno_beat/README.md new file mode 100644 index 00000000..582ceb0e --- /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 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