Skip to content

Latest changes #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions exercises/00-welcome/README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
3 changes: 1 addition & 2 deletions exercises/01-hello-world/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@


# You have to print `Hello World` in the console

# You have to print `Hello World` in the console
2 changes: 0 additions & 2 deletions exercises/01.1-Access-and-Retrieve/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
#2. change 'thursday'a value here to None

#3. print the position of step 2


4 changes: 1 addition & 3 deletions exercises/01.2-Retrieve-items/app.py
Original file line number Diff line number Diff line change
@@ -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:
21 changes: 20 additions & 1 deletion exercises/01.3-Print-the-last-one/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
3 changes: 0 additions & 3 deletions exercises/01.4-Add-item-to-list/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,3 @@

#The magic is here:



print(my_list)
26 changes: 19 additions & 7 deletions exercises/01.4-Add-item-to-list/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions exercises/02.1-Loop-from-the-top/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@

#The magic pass below:




1 change: 1 addition & 0 deletions exercises/02.4-One_last_looping/app.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
my_sample_list = ['Esmeralda','Kiko','Ruth','Lebron','Pedro','Maria','Lou','Fernando','Cesco','Bart','Annie']

#Your code here:

2 changes: 1 addition & 1 deletion exercises/02.4-One_last_looping/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 0 additions & 3 deletions exercises/02.5-Finding_wally/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@

#Your code here:

for name in range(len(people)):
if people[name] == "Wally":
print(name)
5 changes: 0 additions & 5 deletions exercises/04-mixed_list/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
7 changes: 3 additions & 4 deletions exercises/04.1-count_on/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions exercises/04.1-count_on/app.py
Original file line number Diff line number Diff line change
@@ -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)
29 changes: 29 additions & 0 deletions exercises/04.1-count_on/test.py
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion exercises/05-Sum_all_items/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def sum_all_values(items):

total= 0
#The magic happens here:


return total
print(sum_all_values(my_sample_list))
2 changes: 2 additions & 0 deletions exercises/06.1-Everything_is_awesome/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ def my_function(numbers):

return new_list
print(my_function(my_list))


Original file line number Diff line number Diff line change
@@ -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
```


Expand All @@ -38,4 +32,7 @@ Example Output on the console:
.
.
LIFTOFF
```
```

💡Hint:
https://www.w3schools.com/python/python_while_loops.asp
2 changes: 2 additions & 0 deletions exercises/07-Do_while/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

#Your code go here:
44 changes: 44 additions & 0 deletions exercises/07-Do_while/test.py
Original file line number Diff line number Diff line change
@@ -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
Empty file removed exercises/07-Dowhile_DO_DO/app.py
Empty file.
Empty file removed exercises/07-Dowhile_DO_DO/test.py
Empty file.
6 changes: 5 additions & 1 deletion exercises/13.4-Making_HTML_with_filter_and_maP/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
```py
Expexted:
<ul><li>Red</li><li>Orange</li><li>Pink</li><li>Violet</li></ul>
```
```

# 💡Hint:
Maybe you have to use filter and map function
Set values to the news variables
3 changes: 0 additions & 3 deletions exercises/13.4-Making_HTML_with_filter_and_maP/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@

#Your code go here:

filter_colors = list(filter(lambda color: color["sexy"],all_colors))
general_li = list(map(lambda color: "<li>"+color["label"]+"</li>", filter_colors))
print("<ul>" + ''.join(general_li) + "</ul>")
27 changes: 27 additions & 0 deletions exercises/13.4-Making_HTML_with_filter_and_maP/test.py
Original file line number Diff line number Diff line change
@@ -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")
5 changes: 4 additions & 1 deletion exercises/14.1-Parking_lot_check/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -23,3 +24,5 @@ const state = {

💡Hints
You have to do a nested loop
Declare a variables to store the value
Compare the statements
9 changes: 9 additions & 0 deletions exercises/14.1-Parking_lot_check/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
parking_state = [
[1,1,1],
[0,0,0],
[1,1,2]
]

#Your code go here:


Loading