diff --git a/exercises/00-welcome/README.md b/exercises/00-welcome/README.md index 7c26e75b..4dbf4e65 100644 --- a/exercises/00-welcome/README.md +++ b/exercises/00-welcome/README.md @@ -1,7 +1,5 @@ # 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/app.py b/exercises/01-hello-world/app.py index d091b64f..c6d1c343 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,4 +1,3 @@ -# You have to print `Hello World` in the console - +# You have to print `Hello World` in the console \ 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 39ff0606..76882c24 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -6,5 +6,3 @@ #2. change 'thursday'a value here to None #3. print the position of step 2 - - diff --git a/exercises/01.2-Retrieve-items/app.py b/exercises/01.2-Retrieve-items/app.py index d4305d84..dfbb1cd9 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -1,5 +1,3 @@ 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 in the console the 1st and 4th element from the list: diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index 551f30e1..d0c36f4b 100644 --- a/exercises/01.3-Print-the-last-one/test.py +++ b/exercises/01.3-Print-the-last-one/test.py @@ -4,7 +4,8 @@ import pytest import os -from app import the_last_one +# from app import the_last_one +import app sys.stdout = buffer = io.StringIO() @@ -24,3 +25,21 @@ def test_import_random(): f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') content = f.read() assert content.find("import random") > 0 + +@pytest.mark.it("Create the variable the_last_one") +def test_create(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("the_last_one") > 0 + +@pytest.mark.it("Assign the last number to the variable") +def test_assing(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("the_last_one = my_stupid_list[-1]") > 0 + +@pytest.mark.it("Print the last element") +def test_output(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("print(the_last_one)") > 0 \ 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 index 9f98be68..4b67b45d 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -5,6 +5,3 @@ #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 index 20bf728b..f9403f9a 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -8,17 +8,29 @@ 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("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("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 + +@pytest.mark.it("Use the for loop") +def test_for(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("for x in range(1, 10):") > 0 + +@pytest.mark.it("Add the ten random numbers to the list") +def test_add(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("my_list.append(random.randint(1,100))") > 0 \ 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 index 2b4e6a31..21838141 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -2,6 +2,3 @@ #The magic pass below: - - - diff --git a/exercises/02.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index c2d1a72c..268cf7bc 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -1,3 +1,4 @@ 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 index 3006fd91..8b61563c 100644 --- a/exercises/02.4-One_last_looping/test.py +++ b/exercises/02.4-One_last_looping/test.py @@ -12,7 +12,7 @@ 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") +@pytest.mark.it("Have to loop the entire list") def test_use_foor(): captured = buffer.getvalue() diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index 5ae03d3e..4eb9f6d6 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -2,6 +2,3 @@ #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/04-mixed_list/test.py b/exercises/04-mixed_list/test.py index c28fa93a..296c8936 100644 --- a/exercises/04-mixed_list/test.py +++ b/exercises/04-mixed_list/test.py @@ -18,11 +18,6 @@ def test_use_for_loop(): 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(): diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md index 2b165734..7b920079 100644 --- a/exercises/04.1-count_on/README.md +++ b/exercises/04.1-count_on/README.md @@ -11,12 +11,11 @@ Would you be so kind to add all the items with data-type object into the hello l 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)) +for x in my_list: + print(x) ``` # 📝Instructions: 1. Loop the given list 2. Push the arrays found to an new list called hello -3. Console log the variable hello +3. Print the variable hello diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index 2dfcfb3f..1384dfe0 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,9 +1,7 @@ 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 index e69de29b..c3cd3f65 100644 --- a/exercises/04.1-count_on/test.py +++ b/exercises/04.1-count_on/test.py @@ -0,0 +1,29 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Cool !!! 😎 You have the all data-type object") +def test_all_data_type(): + captured = buffer.getvalue() + assert "[[2, 1], {'name': 'juan'}]\n" in captured + +@pytest.mark.it("You used to append the return values to the hello variable, that's very good") +def test_append(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("append") > 0 + +@pytest.mark.it("The if/elif statement was used") +def test_if(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("if") > 0 + +def test_elif(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("elif") > 0 \ No newline at end of file diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 534d4601..c9d38ec2 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -5,7 +5,7 @@ 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/06.1-Everything_is_awesome/app.py b/exercises/06.1-Everything_is_awesome/app.py index a70b66b7..a50ac8b9 100644 --- a/exercises/06.1-Everything_is_awesome/app.py +++ b/exercises/06.1-Everything_is_awesome/app.py @@ -7,3 +7,5 @@ def my_function(numbers): return new_list print(my_function(my_list)) + + diff --git a/exercises/07-Dowhile_DO_DO/README.md b/exercises/07-Do_while/README.md similarity index 50% rename from exercises/07-Dowhile_DO_DO/README.md rename to exercises/07-Do_while/README.md index 8d48f90f..9ec56e19 100644 --- a/exercises/07-Dowhile_DO_DO/README.md +++ b/exercises/07-Do_while/README.md @@ -1,18 +1,12 @@ # `07` D0 While DO DO DO -The do{}while(); is another loop example in python is less commonly used but it is a loop +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) +x = 1 +while x < 6: + print(x) + x += 1 ``` @@ -38,4 +32,7 @@ Example Output on the console: . . LIFTOFF -``` \ No newline at end of file +``` + +💡Hint: +https://www.w3schools.com/python/python_while_loops.asp \ No newline at end of file diff --git a/exercises/07-Do_while/app.py b/exercises/07-Do_while/app.py new file mode 100644 index 00000000..5a8b0ad3 --- /dev/null +++ b/exercises/07-Do_while/app.py @@ -0,0 +1,2 @@ + +#Your code go here: diff --git a/exercises/07-Do_while/test.py b/exercises/07-Do_while/test.py new file mode 100644 index 00000000..025bd228 --- /dev/null +++ b/exercises/07-Do_while/test.py @@ -0,0 +1,44 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("You have a good list numbers with exclamation sign!!! 😃") +def test_output(): + captured = buffer.getvalue() + assert "20 !\n19\n18\n17\n16\n15 !\n14\n13\n12\n11\n10 !\n9\n8\n7\n6\n5 !\n4\n3\n2\n1\nLIFTOFF\n" in captured + + +@pytest.mark.it("Declare the variable and asign the value of 20") +def test_variable(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("20") > 0 + +@pytest.mark.it("While loop") +def test_while(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("while") > 0 + + +@pytest.mark.it("Conditional statement was declared") +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 + +@pytest.mark.it("Print the 'LIFTOFF' to the end") +def test_liftoff(): + f = open(os.path.dirname(os.path.abspath(__file__))+ '/app.py') + content = f.read() + assert content.find("LIFTOFF") > 0 \ No newline at end of file diff --git a/exercises/07-Dowhile_DO_DO/app.py b/exercises/07-Dowhile_DO_DO/app.py deleted file mode 100644 index e69de29b..00000000 diff --git a/exercises/07-Dowhile_DO_DO/test.py b/exercises/07-Dowhile_DO_DO/test.py deleted file mode 100644 index e69de29b..00000000 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 15f778e7..32f7d4a8 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 @@ -5,4 +5,8 @@ ```py Expexted: -``` \ No newline at end of file +``` + +# 💡Hint: +Maybe you have to use filter and map function +Set values to the news variables 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 7c19e703..9afb26dd 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 @@ -10,6 +10,3 @@ #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("") \ 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 index e69de29b..d636c6dc 100644 --- a/exercises/13.4-Making_HTML_with_filter_and_maP/test.py +++ b/exercises/13.4-Making_HTML_with_filter_and_maP/test.py @@ -0,0 +1,27 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + + +@pytest.mark.it("Print the list of color in the console") +def test_output(): + captured = buffer.getvalue() + assert "\n" in captured + + +@pytest.mark.it("Use the filter function") +def test_filter(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find("filter") + + +@pytest.mark.it("Use map function") +def test_map(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("map") \ 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 44f78f8d..c67ee4b8 100644 --- a/exercises/14.1-Parking_lot_check/README.md +++ b/exercises/14.1-Parking_lot_check/README.md @@ -14,7 +14,8 @@ parking_state = [ ``` # 📝Instructions -1. Create a function getParkingLotState() that returns an object with totalSlots, availableSlots and occupiedSlots like the following: +1. Create a function get_parking_lot() that returns an object +with total_slots, available_slots and occupied_slots like the following: const state = { totalSlots: 12, availableSlots: 3, @@ -23,3 +24,5 @@ const state = { 💡Hints You have to do a nested loop +Declare a variables to store the value +Compare the statements diff --git a/exercises/14.1-Parking_lot_check/app.py b/exercises/14.1-Parking_lot_check/app.py index e69de29b..61d52fbe 100644 --- a/exercises/14.1-Parking_lot_check/app.py +++ b/exercises/14.1-Parking_lot_check/app.py @@ -0,0 +1,9 @@ +parking_state = [ + [1,1,1], + [0,0,0], + [1,1,2] +] + +#Your code go here: + + diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py index e69de29b..c10541f5 100644 --- a/exercises/14.1-Parking_lot_check/test.py +++ b/exercises/14.1-Parking_lot_check/test.py @@ -0,0 +1,42 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + +import app +import pytest + +@pytest.mark.it("Print the object") +def test_output(): + captured = buffer.getvalue() + assert "{'total': 9, 'occupied': 5, 'available': 1}\n" in captured + +@pytest.mark.it("Create a get_parking_lot function") +def test_function(): + f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') + content = f.read() + assert content.find("get_parking_lot") > 0 + +@pytest.mark.it("Make a for loop") +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("Using conditional statements") +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 + +@pytest.mark.it("Push the value into the new variables") +def test_append(): + f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') + content = f.read() + assert content.find('append') > 0 + + + diff --git a/exercises/15-Techno_beat/README.md b/exercises/15-Techno_beat/README.md index 582ceb0e..e5d13d63 100644 --- a/exercises/15-Techno_beat/README.md +++ b/exercises/15-Techno_beat/README.md @@ -8,7 +8,7 @@ You are working with a DJ and he needs a program that can create a beats for his 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 +# Constraints If you find the number One (1) three times in a row, should ALSO ADD to the string "!!!Break the base!!!" ```py @@ -24,4 +24,6 @@ Drop the base Drop the base Drop the base !!!Break the base!!! 💡Hints -Remember to use helper variables \ No newline at end of file +Remember to use helper variables +Declare a variable to store +Declare a variable to count and sum diff --git a/exercises/15-Techno_beat/app.py b/exercises/15-Techno_beat/app.py index e69de29b..725de511 100644 --- a/exercises/15-Techno_beat/app.py +++ b/exercises/15-Techno_beat/app.py @@ -0,0 +1,8 @@ + + +# Your code go above, nothing to change after this line: +print(lyrics_generator([0,0,1,1,0,0,0])) +print(lyrics_generator([0,0,1,1,1,0,0,0])) +print(lyrics_generator([0,0,0])) +print(lyrics_generator([1,0,1])) +print(lyrics_generator([1,1,1])) \ No newline at end of file diff --git a/exercises/15-Techno_beat/test.py b/exercises/15-Techno_beat/test.py index e69de29b..6a5729cb 100644 --- a/exercises/15-Techno_beat/test.py +++ b/exercises/15-Techno_beat/test.py @@ -0,0 +1,42 @@ +import io +import os +import sys +sys.stdout = buffer = io.StringIO() + + +import app +import pytest + +@pytest.mark.it("Create a function lyrics_generator") +def test_function(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert content.find("lyrics_generator") + + +@pytest.mark.it("Use for loop") +def test_for(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert content.find("for") + +@pytest.mark.it("Use conditionals if/elif/else") +def test_conditinal(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert content.find("for") + +@pytest.mark.it("Store the value in the variable that you have to return") +def test_append(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert content.find("append") + +@pytest.mark.it("Print the strings like song") +def test_output(): + captured = buffer.getvalue() + assert "['boom', 'boom', 'Drop the base', 'Drop the base', 'boom', 'boom', 'boom']\n['boom', 'boom', 'Drop the base', 'Drop the base', 'Drop the base', '!!!Break the base', 'boom', 'boom', 'boom']\n['boom', 'boom', 'boom']\n['Drop the base', 'boom', 'Drop the base']\n['Drop the base', 'Drop the base', 'Drop the base', '!!!Break the base']\n" in captured + + + +