From fe35335324752e861f314acb7057685ce4a45645 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 17 Sep 2019 02:11:59 +0000 Subject: [PATCH 01/14] readme count on --- exercises/01-hello-world/app.py | 2 +- exercises/02.5-Finding_wally/app.py | 4 ---- exercises/04.1-count_on/README.md | 7 +++---- exercises/04.1-count_on/app.py | 10 ++++++---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py index 6ffb617d..7102d6d4 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,5 +1,5 @@ #You have to print `hello` in the console, your code go here: -print("Hello World") + diff --git a/exercises/02.5-Finding_wally/app.py b/exercises/02.5-Finding_wally/app.py index 5ae03d3e..8215cf02 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -1,7 +1,3 @@ people = [ 'Lebron','Aaliyah','Diamond','Dominique','Aliyah','Jazmin','Darnell','Hatfield','Hawkins','Hayden','Hayes','Haynes','Hays','Head','Heath','Hebert','Henderson','Hendricks','Hendrix','Henry','Hensley','Henson','Herman','Hernandez','Herrera','Herring','Hess','Hester','Hewitt','Hickman','Hicks','Higgins','Hill','Hines','Hinton','Hobbs','Hodge','Hodges','Hoffman','Hogan','Holcomb','Holden','Holder','Holland','Holloway','Holman','Holmes','Holt','Hood','Hooper','Hoover','Hopkins','Hopper','Horn','Horne','Horton','House','Houston','Howard','Howe','Howell','Hubbard','Huber','Hudson','Huff','Wally','Hughes','Hull','Humphrey','Hunt','Hunter','Hurley','Hurst','Hutchinson','Hyde','Ingram','Irwin','Jackson','Jacobs','Jacobson','James','Jarvis','Jefferson','Jenkins','Jennings','Jensen','Jimenez','Johns','Johnson','Johnston','Jones','Jordan','Joseph','Joyce','Joyner','Juarez','Justice','Kane','Kaufman','Keith','Keller','Kelley','Kelly','Kemp','Kennedy','Kent','Kerr','Key','Kidd','Kim','King','Kinney','Kirby','Kirk','Kirkland','Klein','Kline','Knapp','Knight','Knowles','Knox','Koch','Kramer','Lamb','Lambert','Lancaster','Landry','Lane','Lang','Langley','Lara','Larsen','Larson','Lawrence','Lawson','Le','Leach','Leblanc','Lee','Leon','Leonard','Lester','Levine','Levy','Lewis','Lindsay','Lindsey','Little','Livingston','Lloyd','Logan','Long','Lopez','Lott','Love','Lowe','Lowery','Lucas','Luna','Lynch','Lynn','Lyons','Macdonald','Macias','Mack','Madden','Maddox','Maldonado','Malone','Mann','Manning','Marks','Marquez','Marsh','Marshall','Martin','Martinez','Mason','Massey','Mathews','Mathis','Matthews','Maxwell','May','Mayer','Maynard','Mayo','Mays','Mcbride','Mccall','Mccarthy','Mccarty','Mcclain','Mcclure','Mcconnell','Mccormick','Mccoy','Mccray','Wally','Mcdaniel','Mcdonald','Mcdowell','Mcfadden','Mcfarland','Mcgee','Mcgowan','Mcguire','Mcintosh','Mcintyre','Mckay','Mckee','Mckenzie','Mckinney','Mcknight','Mclaughlin','Mclean','Mcleod','Mcmahon','Mcmillan','Mcneil','Mcpherson','Meadows','Medina','Mejia','Melendez','Melton','Mendez','Mendoza','Mercado','Mercer','Merrill','Merritt','Meyer','Meyers','Michael','Middleton','Miles','Miller','Mills','Miranda','Mitchell','Molina','Monroe','Lucas','Jake','Scott','Amy','Molly','Hannah','Lucas'] #Your code here: - -for name in range(len(people)): - if people[name] == "Wally": - print(name) \ No newline at end of file diff --git a/exercises/04.1-count_on/README.md b/exercises/04.1-count_on/README.md index 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..813e1c88 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -2,8 +2,10 @@ 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] != +# hello = [] +# for x in my_list: + +# print(hello) -print(hello) +for x in my_list: + print(x) \ No newline at end of file From 041b73b26c56ab3dc8151f789f60f7ed261049ed Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 17 Sep 2019 02:26:03 +0000 Subject: [PATCH 02/14] pytest count on --- exercises/04.1-count_on/app.py | 8 +++----- exercises/04.1-count_on/test.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index 813e1c88..4f7aebc5 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,11 +1,9 @@ my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] +hello = [] #your code go here: -# hello = [] -# for x in my_list: + -# print(hello) +print(hello) -for x in my_list: - print(x) \ No newline at end of file diff --git a/exercises/04.1-count_on/test.py b/exercises/04.1-count_on/test.py index e69de29b..ebb7ac85 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(): + capatured = buffer.gervalue() + 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 From 8f6d60f1f15c5c190b2559b4dc363470097025ac Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 17 Sep 2019 02:48:30 +0000 Subject: [PATCH 03/14] do while --- exercises/04.1-count_on/app.py | 4 +- exercises/04.1-count_on/test.py | 2 +- .../README.md | 21 ++++----- exercises/07-Do_while/app.py | 2 + exercises/07-Do_while/test.py | 44 +++++++++++++++++++ exercises/07-Dowhile_DO_DO/app.py | 0 exercises/07-Dowhile_DO_DO/test.py | 0 7 files changed, 57 insertions(+), 16 deletions(-) rename exercises/{07-Dowhile_DO_DO => 07-Do_while}/README.md (50%) create mode 100644 exercises/07-Do_while/app.py create mode 100644 exercises/07-Do_while/test.py delete mode 100644 exercises/07-Dowhile_DO_DO/app.py delete mode 100644 exercises/07-Dowhile_DO_DO/test.py diff --git a/exercises/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index 4f7aebc5..bfefd295 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -4,6 +4,4 @@ hello = [] #your code go here: - -print(hello) - +print(hello) \ No newline at end of file diff --git a/exercises/04.1-count_on/test.py b/exercises/04.1-count_on/test.py index ebb7ac85..c3cd3f65 100644 --- a/exercises/04.1-count_on/test.py +++ b/exercises/04.1-count_on/test.py @@ -8,7 +8,7 @@ @pytest.mark.it("Cool !!! 😎 You have the all data-type object") def test_all_data_type(): - capatured = buffer.gervalue() + 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") 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 From ab025a4c23f0dc617fba2084916abd526b79a409 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 17 Sep 2019 05:25:01 +0000 Subject: [PATCH 04/14] pytest --- exercises/01.1-Access-and-Retrieve/app.py | 1 - exercises/01.2-Retrieve-items/app.py | 1 - exercises/01.3-Print-the-last-one/app.py | 2 +- exercises/01.4-Add-item-to-list/app.py | 2 +- exercises/01.4-Add-item-to-list/test.py | 14 +++++++------- exercises/02-Loop-list/app.py | 1 - exercises/02.1-Loop-from-the-top/app.py | 4 ---- exercises/02.4-One_last_looping/app.py | 2 +- 8 files changed, 10 insertions(+), 17 deletions(-) diff --git a/exercises/01.1-Access-and-Retrieve/app.py b/exercises/01.1-Access-and-Retrieve/app.py index 39ff0606..8d980556 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -7,4 +7,3 @@ #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..2db83581 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -2,4 +2,3 @@ #output the 1st and 4th element from the list: - diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index 76b74ea6..f33009bc 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -1,5 +1,5 @@ #You have to import random function - +import random def generate_random_list(): aux_list = [] diff --git a/exercises/01.4-Add-item-to-list/app.py b/exercises/01.4-Add-item-to-list/app.py index 9f98be68..440a98e8 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -1,5 +1,5 @@ #Remember import random function here: -import random + my_list = [4,5,734,43,45] diff --git a/exercises/01.4-Add-item-to-list/test.py b/exercises/01.4-Add-item-to-list/test.py index 20bf728b..5a054a81 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -8,14 +8,14 @@ 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(): diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index b2ab27c2..63d90746 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,4 +1,3 @@ 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.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py index 2b4e6a31..ad748f31 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -1,7 +1,3 @@ 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.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index c2d1a72c..afdad81b 100644 --- a/exercises/02.4-One_last_looping/app.py +++ b/exercises/02.4-One_last_looping/app.py @@ -1,3 +1,3 @@ my_sample_list = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie'] -#Your code here: +#Your code here: \ No newline at end of file From 3a5d66d0fa4ac05e42216c6864676d01e729b07b Mon Sep 17 00:00:00 2001 From: ESPINO Date: Tue, 17 Sep 2019 23:44:57 +0000 Subject: [PATCH 05/14] pytest count on --- exercises/01.3-Print-the-last-one/app.py | 2 ++ exercises/01.3-Print-the-last-one/test.py | 21 ++++++++++++- exercises/01.4-Add-item-to-list/app.py | 5 +-- exercises/01.4-Add-item-to-list/test.py | 12 +++++++ exercises/04.1-count_on/app.py | 2 +- exercises/14.1-Parking_lot_check/app.py | 38 +++++++++++++++++++++++ 6 files changed, 74 insertions(+), 6 deletions(-) diff --git a/exercises/01.3-Print-the-last-one/app.py b/exercises/01.3-Print-the-last-one/app.py index f33009bc..682e7fa4 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -12,3 +12,5 @@ def generate_random_list(): my_stupid_list = generate_random_list() #Feel happy to write the code below, good luck: +the_last_one = my_stupid_list[-1] +print(the_last_one) \ No newline at end of file diff --git a/exercises/01.3-Print-the-last-one/test.py b/exercises/01.3-Print-the-last-one/test.py index 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 440a98e8..4b67b45d 100644 --- a/exercises/01.4-Add-item-to-list/app.py +++ b/exercises/01.4-Add-item-to-list/app.py @@ -1,10 +1,7 @@ #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 index 5a054a81..f9403f9a 100644 --- a/exercises/01.4-Add-item-to-list/test.py +++ b/exercises/01.4-Add-item-to-list/test.py @@ -22,3 +22,15 @@ 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/04.1-count_on/app.py b/exercises/04.1-count_on/app.py index bfefd295..16bdb010 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -4,4 +4,4 @@ hello = [] #your code go here: -print(hello) \ No newline at end of file +print(hello) diff --git a/exercises/14.1-Parking_lot_check/app.py b/exercises/14.1-Parking_lot_check/app.py index e69de29b..a15c91b6 100644 --- a/exercises/14.1-Parking_lot_check/app.py +++ b/exercises/14.1-Parking_lot_check/app.py @@ -0,0 +1,38 @@ +parking_state = [ + [1,1,1], + [0,0,0], + [1,1,2] +] + + +#Your code go here: + +total_slots = [] +available_slots = [] +occupied_slots = [] +not_parking_slots = [] +new_dict = {} + + +for x in parking_state: + for j in x: + if j == 1: + occupied_slots.append(j) + +for numb in parking_state: + for n in numb: + if n ==2: + available_slots.append(n) + +for number in parking_state: + for o in number: + total_slots.append(o) + +for h in parking_state: + for k in h: + if k == 0: + not_parking_slots.append(k) + +new_dict.update({"total_slots" : len(total_slots), "occupied_slots":len(occupied_slots), "available_slots": len(available_slots), "not_parking_slots": len(not_parking_slots)}) +print(new_dict) + From 023209199b41f6cf5ef9f47c101575b3910dc977 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 22:12:22 +0000 Subject: [PATCH 06/14] pytest --- exercises/00-welcome/README.md | 2 -- exercises/01-hello-world/app.py | 1 + exercises/01.1-Access-and-Retrieve/app.py | 3 +-- exercises/01.2-Retrieve-items/app.py | 3 +-- exercises/01.3-Print-the-last-one/app.py | 4 +--- exercises/02-Loop-list/app.py | 1 + exercises/02.1-Loop-from-the-top/app.py | 1 + exercises/02.4-One_last_looping/app.py | 3 ++- exercises/02.4-One_last_looping/test.py | 2 +- exercises/02.5-Finding_wally/app.py | 1 + exercises/04-mixed_list/test.py | 5 ----- exercises/04.1-count_on/app.py | 2 +- exercises/05-Sum_all_items/app.py | 3 ++- 13 files changed, 13 insertions(+), 18 deletions(-) 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 7102d6d4..9f675d93 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -3,3 +3,4 @@ #You have to print `hello` in the console, your code go here: +print("Hello World") \ 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 8d980556..c30a10b7 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -2,8 +2,7 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here - +print(my_list[2]) #2. change 'thursday'a value here to None #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 2db83581..dfbb1cd9 100644 --- a/exercises/01.2-Retrieve-items/app.py +++ b/exercises/01.2-Retrieve-items/app.py @@ -1,4 +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/app.py b/exercises/01.3-Print-the-last-one/app.py index 682e7fa4..76b74ea6 100644 --- a/exercises/01.3-Print-the-last-one/app.py +++ b/exercises/01.3-Print-the-last-one/app.py @@ -1,5 +1,5 @@ #You have to import random function -import random + def generate_random_list(): aux_list = [] @@ -12,5 +12,3 @@ def generate_random_list(): my_stupid_list = generate_random_list() #Feel happy to write the code below, good luck: -the_last_one = my_stupid_list[-1] -print(the_last_one) \ No newline at end of file diff --git a/exercises/02-Loop-list/app.py b/exercises/02-Loop-list/app.py index 63d90746..b2ab27c2 100644 --- a/exercises/02-Loop-list/app.py +++ b/exercises/02-Loop-list/app.py @@ -1,3 +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.1-Loop-from-the-top/app.py b/exercises/02.1-Loop-from-the-top/app.py index ad748f31..21838141 100644 --- a/exercises/02.1-Loop-from-the-top/app.py +++ b/exercises/02.1-Loop-from-the-top/app.py @@ -1,3 +1,4 @@ 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.4-One_last_looping/app.py b/exercises/02.4-One_last_looping/app.py index afdad81b..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: \ No newline at end of file +#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 8215cf02..4eb9f6d6 100644 --- a/exercises/02.5-Finding_wally/app.py +++ b/exercises/02.5-Finding_wally/app.py @@ -1,3 +1,4 @@ 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: + 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/app.py b/exercises/04.1-count_on/app.py index 16bdb010..1384dfe0 100644 --- a/exercises/04.1-count_on/app.py +++ b/exercises/04.1-count_on/app.py @@ -1,7 +1,7 @@ my_list = [42, True, "towel", [2,1], 'hello', 34.4, {"name": "juan"}] -hello = [] + #your code go here: print(hello) diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 534d4601..29b7a8d0 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -5,7 +5,8 @@ def sum_all_values(items): total= 0 #The magic happens here: - + for x in my_sample_list: + total = total + x return total print(sum_all_values(my_sample_list)) \ No newline at end of file From c6865cac2273f363d3bebc66608b414296fc2bb4 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 22:48:56 +0000 Subject: [PATCH 07/14] pytest parking slots --- exercises/14.1-Parking_lot_check/README.md | 2 +- exercises/14.1-Parking_lot_check/app.py | 48 ++++++++-------------- exercises/14.1-Parking_lot_check/test.py | 29 +++++++++++++ 3 files changed, 47 insertions(+), 32 deletions(-) diff --git a/exercises/14.1-Parking_lot_check/README.md b/exercises/14.1-Parking_lot_check/README.md index 44f78f8d..71ec50b1 100644 --- a/exercises/14.1-Parking_lot_check/README.md +++ b/exercises/14.1-Parking_lot_check/README.md @@ -14,7 +14,7 @@ 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_state() that returns an object with total_slots, available_slots and occupied_slots like the following: const state = { totalSlots: 12, availableSlots: 3, diff --git a/exercises/14.1-Parking_lot_check/app.py b/exercises/14.1-Parking_lot_check/app.py index a15c91b6..0d43b522 100644 --- a/exercises/14.1-Parking_lot_check/app.py +++ b/exercises/14.1-Parking_lot_check/app.py @@ -4,35 +4,21 @@ [1,1,2] ] - -#Your code go here: - -total_slots = [] -available_slots = [] -occupied_slots = [] -not_parking_slots = [] -new_dict = {} - - -for x in parking_state: - for j in x: - if j == 1: - occupied_slots.append(j) - -for numb in parking_state: - for n in numb: - if n ==2: - available_slots.append(n) - -for number in parking_state: - for o in number: - total_slots.append(o) - -for h in parking_state: - for k in h: - if k == 0: - not_parking_slots.append(k) - -new_dict.update({"total_slots" : len(total_slots), "occupied_slots":len(occupied_slots), "available_slots": len(available_slots), "not_parking_slots": len(not_parking_slots)}) -print(new_dict) +total = [] +occupied = [] +available = [] +not_parking = [] +parking_slots = {} +for numbs in parking_state: + for digit in numbs: + total.append(digit) + if digit ==1: + occupied.append(digit) + elif digit == 2: + available.append(digit) + elif digit == 0: + not_parking.append(digit) + +parking_slots.update({"total": len(total), "occupied": len(occupied), "available": len(available), "not_parking": len(not_parking)}) +print(parking_slots) diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py index e69de29b..9d5577cc 100644 --- a/exercises/14.1-Parking_lot_check/test.py +++ b/exercises/14.1-Parking_lot_check/test.py @@ -0,0 +1,29 @@ +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 "\n" in captured + +@pytest.mark.it("Have 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') + + From 795eeafa86e4333b8d4bcedc8916dfb2ea6d656c Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 23:01:28 +0000 Subject: [PATCH 08/14] pytest --- exercises/01-hello-world/app.py | 3 --- exercises/01.1-Access-and-Retrieve/app.py | 2 +- exercises/05-Sum_all_items/app.py | 3 +-- exercises/06.1-Everything_is_awesome/app.py | 2 ++ 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/exercises/01-hello-world/app.py b/exercises/01-hello-world/app.py index 9f675d93..f18a7317 100644 --- a/exercises/01-hello-world/app.py +++ b/exercises/01-hello-world/app.py @@ -1,6 +1,3 @@ #You have to print `hello` in the console, your code go here: - - -print("Hello World") \ 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 c30a10b7..76882c24 100644 --- a/exercises/01.1-Access-and-Retrieve/app.py +++ b/exercises/01.1-Access-and-Retrieve/app.py @@ -2,7 +2,7 @@ my_list = ['sunday','monday','tuesday','wednesday','thursday','friday','saturday'] #1. print the item here -print(my_list[2]) + #2. change 'thursday'a value here to None #3. print the position of step 2 diff --git a/exercises/05-Sum_all_items/app.py b/exercises/05-Sum_all_items/app.py index 29b7a8d0..c9d38ec2 100644 --- a/exercises/05-Sum_all_items/app.py +++ b/exercises/05-Sum_all_items/app.py @@ -5,8 +5,7 @@ def sum_all_values(items): total= 0 #The magic happens here: - for x in my_sample_list: - total = total + x + 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)) + + From 02113e3351035553e85e444fce6c75c388c702fe Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 23:18:03 +0000 Subject: [PATCH 09/14] pytest --- exercises/14.1-Parking_lot_check/README.md | 2 +- exercises/14.1-Parking_lot_check/app.py | 25 +++++++++++----------- exercises/14.1-Parking_lot_check/test.py | 6 ++++++ 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/exercises/14.1-Parking_lot_check/README.md b/exercises/14.1-Parking_lot_check/README.md index 71ec50b1..e5d6c1bc 100644 --- a/exercises/14.1-Parking_lot_check/README.md +++ b/exercises/14.1-Parking_lot_check/README.md @@ -14,7 +14,7 @@ parking_state = [ ``` # 📝Instructions -1. Create a function get_parking_lot_state() that returns an object with total_slots, available_slots and occupied_slots 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, diff --git a/exercises/14.1-Parking_lot_check/app.py b/exercises/14.1-Parking_lot_check/app.py index 0d43b522..64c431db 100644 --- a/exercises/14.1-Parking_lot_check/app.py +++ b/exercises/14.1-Parking_lot_check/app.py @@ -4,21 +4,22 @@ [1,1,2] ] +#Your code go here: + total = [] occupied = [] available = [] -not_parking = [] parking_slots = {} -for numbs in parking_state: - for digit in numbs: - total.append(digit) - if digit ==1: - occupied.append(digit) - elif digit == 2: - available.append(digit) - elif digit == 0: - not_parking.append(digit) -parking_slots.update({"total": len(total), "occupied": len(occupied), "available": len(available), "not_parking": len(not_parking)}) -print(parking_slots) +def get_parking_lot(spaces): + for numb in spaces: + for digit in numb: + total.append(digit) + if digit == 1: + occupied.append(digit) + elif digit == 2: + available.append(digit) + parking_slots.update({'total': len(total), 'occupied': len(occupied), 'available': len(available)}) + return parking_slots +print(get_parking_lot(parking_state)) diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py index 9d5577cc..2d7e5d36 100644 --- a/exercises/14.1-Parking_lot_check/test.py +++ b/exercises/14.1-Parking_lot_check/test.py @@ -11,6 +11,12 @@ def test_output(): captured = buffer.getvalue() assert "\n" in captured +@pytest.mark.it("Declare 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("Have make a for loop") def test_for(): f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') From 491851433c863ab525512bff07ee61c8af1ba112 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 23:23:13 +0000 Subject: [PATCH 10/14] pytest --- exercises/15-Techno_beat/test.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/exercises/15-Techno_beat/test.py b/exercises/15-Techno_beat/test.py index e69de29b..20208c91 100644 --- a/exercises/15-Techno_beat/test.py +++ b/exercises/15-Techno_beat/test.py @@ -0,0 +1,23 @@ +import io +import os +import sys +sys.stdout = buffer.getvalue() + + +import app.py +import pytest + +@pytest.mark.it("") + +@pytest.mark.it("") +def test_(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert conten.fint() + + +@pytest.mark.it("") +def test_(): + f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') + content = f.read() + assert content.find() \ No newline at end of file From f6b3f57e20862cd5856635c32f4e7e685619765e Mon Sep 17 00:00:00 2001 From: ESPINO Date: Wed, 18 Sep 2019 23:57:22 +0000 Subject: [PATCH 11/14] pytest --- exercises/14.1-Parking_lot_check/test.py | 15 +++++++++++---- exercises/15-Techno_beat/test.py | 7 +++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py index 2d7e5d36..e3590cea 100644 --- a/exercises/14.1-Parking_lot_check/test.py +++ b/exercises/14.1-Parking_lot_check/test.py @@ -11,13 +11,13 @@ def test_output(): captured = buffer.getvalue() assert "\n" in captured -@pytest.mark.it("Declare a get_parking_lot function") +@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("Have make a for loop") +@pytest.mark.it("Make a for loop") def test_for(): f = open(os.path.dirname(os.path.abspath(__file__)) + '/app.py') content = f.read() @@ -29,7 +29,14 @@ def test_for(): 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') + 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/test.py b/exercises/15-Techno_beat/test.py index 20208c91..8de22ff5 100644 --- a/exercises/15-Techno_beat/test.py +++ b/exercises/15-Techno_beat/test.py @@ -1,19 +1,22 @@ import io import os import sys -sys.stdout = buffer.getvalue() +sys.stdout = buffer = io.StringIO() import app.py import pytest @pytest.mark.it("") +def test_(): + captured = buffer.getvalue() + assert "\n" in captured @pytest.mark.it("") def test_(): f = open(os.path.dirname(os.path.abspath(__file__)) +'/app.py') content = f.read() - assert conten.fint() + assert content.fint() @pytest.mark.it("") From c98c2f9407a8330591eb5a0994c8248635c375d2 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Thu, 19 Sep 2019 22:11:07 +0000 Subject: [PATCH 12/14] 15-techno beat test and readme --- exercises/15-Techno_beat/app.py | 14 ++++++++++++ exercises/15-Techno_beat/test.py | 39 ++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/exercises/15-Techno_beat/app.py b/exercises/15-Techno_beat/app.py index e69de29b..544c4411 100644 --- a/exercises/15-Techno_beat/app.py +++ b/exercises/15-Techno_beat/app.py @@ -0,0 +1,14 @@ +def lyrics_generator(numbers): + zero = [] + for x in numbers: + if x == 1: + zero.append("Drop the base") + elif x == 0: + zero.append("boom") + return zero + +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 8de22ff5..3399f886 100644 --- a/exercises/15-Techno_beat/test.py +++ b/exercises/15-Techno_beat/test.py @@ -7,20 +7,39 @@ import app.py import pytest -@pytest.mark.it("") -def test_(): - captured = buffer.getvalue() - assert "\n" in captured -@pytest.mark.it("") -def test_(): + + +@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.fint() + assert content.fint("lyrics_generator") -@pytest.mark.it("") -def test_(): +@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() \ No newline at end of file + 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("Add the value to the new list") +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 "\n" in captured + + + + From b126e0dfebd184bc3ae28b1f2f5a6a8b6d410abf Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 21 Sep 2019 14:50:53 +0000 Subject: [PATCH 13/14] techno beat --- exercises/15-Techno_beat/README.md | 6 ++++-- exercises/15-Techno_beat/app.py | 10 ++-------- exercises/15-Techno_beat/test.py | 11 ++++------- 3 files changed, 10 insertions(+), 17 deletions(-) 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 544c4411..725de511 100644 --- a/exercises/15-Techno_beat/app.py +++ b/exercises/15-Techno_beat/app.py @@ -1,12 +1,6 @@ -def lyrics_generator(numbers): - zero = [] - for x in numbers: - if x == 1: - zero.append("Drop the base") - elif x == 0: - zero.append("boom") - return zero + +# 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])) diff --git a/exercises/15-Techno_beat/test.py b/exercises/15-Techno_beat/test.py index 3399f886..6a5729cb 100644 --- a/exercises/15-Techno_beat/test.py +++ b/exercises/15-Techno_beat/test.py @@ -4,17 +4,14 @@ sys.stdout = buffer = io.StringIO() -import app.py +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.fint("lyrics_generator") + assert content.find("lyrics_generator") @pytest.mark.it("Use for loop") @@ -29,7 +26,7 @@ def test_conditinal(): content = f.read() assert content.find("for") -@pytest.mark.it("Add the value to the new list") +@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() @@ -38,7 +35,7 @@ def test_append(): @pytest.mark.it("Print the strings like song") def test_output(): captured = buffer.getvalue() - assert "\n" in captured + 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 From a13d04e04befaacb632f939f0fbde836792b95c5 Mon Sep 17 00:00:00 2001 From: ESPINO Date: Sat, 21 Sep 2019 15:08:44 +0000 Subject: [PATCH 14/14] making html exercise --- .../README.md | 6 ++++- .../app.py | 3 --- .../test.py | 27 +++++++++++++++++++ exercises/14.1-Parking_lot_check/README.md | 5 +++- exercises/14.1-Parking_lot_check/app.py | 16 ----------- exercises/14.1-Parking_lot_check/test.py | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) 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:
  • Red
  • Orange
  • Pink
  • Violet
-``` \ 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("
      " + ''.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 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 e5d6c1bc..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 get_parking_lot() that returns an object with total_slots, available_slots and occupied_slots 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 64c431db..61d52fbe 100644 --- a/exercises/14.1-Parking_lot_check/app.py +++ b/exercises/14.1-Parking_lot_check/app.py @@ -6,20 +6,4 @@ #Your code go here: -total = [] -occupied = [] -available = [] -parking_slots = {} - -def get_parking_lot(spaces): - for numb in spaces: - for digit in numb: - total.append(digit) - if digit == 1: - occupied.append(digit) - elif digit == 2: - available.append(digit) - parking_slots.update({'total': len(total), 'occupied': len(occupied), 'available': len(available)}) - return parking_slots -print(get_parking_lot(parking_state)) diff --git a/exercises/14.1-Parking_lot_check/test.py b/exercises/14.1-Parking_lot_check/test.py index e3590cea..c10541f5 100644 --- a/exercises/14.1-Parking_lot_check/test.py +++ b/exercises/14.1-Parking_lot_check/test.py @@ -9,7 +9,7 @@ @pytest.mark.it("Print the object") def test_output(): captured = buffer.getvalue() - assert "\n" in captured + assert "{'total': 9, 'occupied': 5, 'available': 1}\n" in captured @pytest.mark.it("Create a get_parking_lot function") def test_function():