Skip to content

Commit b152aaa

Browse files
authored
Merge pull request #19 from 4GeeksAcademy/learnpack
migrated to learnpack, added solutions and other minor fixes
2 parents ce28b5f + 4560bb5 commit b152aaa

File tree

17 files changed

+114
-29
lines changed

17 files changed

+114
-29
lines changed

.gitignore

+7-8
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@
44
!.gitignore
55
!.gitpod.yml
66
!.gitpod.Dockerfile
7-
!bc.json
7+
!learn.json
88
!README.md
99

1010
!/exercises
1111
!/exercises/*
1212

13-
*.pyc
14-
__pycache__/
15-
.pytest_cache/
13+
!/.learn
14+
/.learn/**
15+
!/.learn/resets
16+
!/.learn/resets/**
17+
!/.learn/assets
18+
!/.learn/assets/**
1619

17-
!/.breathecode
18-
/.breathecode/**
19-
!/.breathecode/resets
20-
!/.breathecode/resets/**

.gitpod.Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ FROM gitpod/workspace-full:latest
22

33
USER gitpod
44

5-
RUN pip3 install pytest==4.4.2 mock pytest-testdox && npm i breathecode-cli@1.2.70 -g
5+
RUN npm i jest@24.8.0 -g
6+
RUN npm i learnpack -g && learnpack plugins:install learnpack-html
7+

.gitpod.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ ports:
55
- port: 3000
66
onOpen: open-preview
77
tasks:
8-
- command: >
9-
bc run -l python3;
8+
- command: learnpack start
9+
1010
github:
1111
prebuilds:
1212
# enable for the master/default branch (defaults to true)

README.md

+18-6
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,30 @@ These exercises were built in collaboration, we need you! If you find any bugs o
4141

4242
## Local Installation
4343

44-
1) Make sure you have the [breathecode-cli](https://github.com/breatheco-de/breathecode-cli) installed and `node.js` version 10+ and python version 3+. This is the command to install the breathecode-cli
44+
1. Install learnpack, the package manager for learning tutorials and the html compiler plugin for learnpack, make sure you also have node.js 12+:
45+
4546
```
46-
$ npm i breathecode-cli -g
47+
$ npm i learnpack -g
48+
$ learnpack plugins:install learnpack-python
4749
```
4850

49-
2) Clone or download this repository. Once you finish downloading, you will find a new folder with a subdirectory "exercises" that contains all the exercises within.
51+
2. Download this particular exercise using learnpack and `cd` into the folder:
52+
53+
```
54+
$ learnpack download python-beginner-programming-exercises
55+
$ cd python-beginner-programming-exercises
56+
```
5057

51-
3) Start the tutorial/exercises by running the following command from the root of the project:
58+
Note: Once you finish downloading, you will find a "exercises" folder that contains all the exercises within.
59+
60+
3. Start the tutorial/exercises by running the following command at the same level were your bc.json file is:
5261

5362
```sh
54-
$ pip install pytest==4.4.2 mock pytest-testdox
55-
$ breathecode run
63+
$ npm i jest@24.8.0 -g
64+
$ learnpack start
65+
```
66+
67+
Note: The exercises have automatic grading but its very rigid and string, my recomendation is to ignore the tests and use them only as a recomendation or you can get frustrated.
5668
```
5769
5870
## How are the exercises organized?

exercises/01-Console/solution.hide.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# print "Hello World!" on the console
2+
3+
print("Hello World!")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# your code here
2+
3+
color = "Yellow"
4+
print(color)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#your code here
2+
3+
color = "red"
4+
print(color)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# your code here
2+
variables_are_cool = 2345 * 7323
3+
print(variables_are_cool)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
age = int(input('What is your age?\n'))
2+
# CHANGE THE CODE BELOW TO ADD 10 TO AGE
3+
age = age + 10
4+
print("Your age is: "+str(age))

exercises/05-User-Inputed-Values/test.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
import pytest,os,re,io,sys, mock, json
22

3+
@pytest.mark.it('Use the function print()')
4+
def test_for_file_output(capsys):
5+
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
6+
with open(path, 'r') as content_file:
7+
content = content_file.read()
8+
pattern = r"print\s*\("
9+
regex = re.compile(pattern)
10+
assert bool(regex.search(content)) == True
11+
312
@pytest.mark.it("We tried with age 50 and it was supposed to return 60")
4-
def test_t(stdin):
5-
with mock.patch('builtins.input', lambda x: 50):
13+
@mock.patch('builtins.input', lambda x: 50)
14+
def test_plus_ten(stdin):
615
# f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
716
sys.stdout = buffer = io.StringIO()
817
import app
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Set the values for my_var1 and my_var2 here
2+
my_var1 = "Hello"
3+
my_var2 = "World"
4+
5+
## Don't change below this line
6+
the_new_string = my_var1+' '+my_var2
7+
print(the_new_string)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
a = '</title>'
2+
b = '</html>'
3+
c = '<head>'
4+
d = '</body>'
5+
e = '<html>'
6+
f = '</head>'
7+
g = '<title>'
8+
h = '<body>'
9+
10+
# ⬆ DON'T CHANGE THE CODE ABOVE ⬆
11+
# ↓ start coding below here ↓
12+
13+
html_document = e+c+g+a+f+h+d+b
14+
print(html_document)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
total = int(input('How much money do you have in your pocket\n'))
3+
4+
# YOUR CODE HERE
5+
if total > 100:
6+
print("Give me your money!")
7+
elif total > 50:
8+
print("Buy me some coffee you cheap!")
9+
elif total <= 50:
10+
print("You are a poor guy, go away!")

exercises/08.1-How-Much-The-Wedding-Costs/README.es.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
Aquí tenemos una tabla de precios de una compañía de catering de bodas:
44

5-
Hasta 50 personas $4,000
6-
Hasta 100 personas $10,000
7-
Hasta 200 personas $15,000
8-
Más de 200 personas $20,000
9-
5+
| # de invitados | Precio |
6+
| --------------------- | --------- |
7+
| Hasta 50 personas | $4,000 |
8+
| Hasta 100 personas | $10,000 |
9+
| Hasta 200 personas | $15,000 |
10+
| Más de 200 personas | $20,000 |
1011

1112

1213
## 📝 Instrucciones:

exercises/08.1-How-Much-The-Wedding-Costs/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@ tutorial: "https://www.youtube.com/watch?v=Wu7uK8BN4nI"
66

77
Here is a table of prices for a wedding catering company:
88

9-
Up to 50 people $4,000
10-
Up to 100 people $10,000
11-
Up to 200 people $15,000
12-
More than 200 people $20,000
13-
9+
| # of guests | price |
10+
| --------------------- | --------- |
11+
| Up to 50 people | $4,000 |
12+
| Up to 100 people | $10,000 |
13+
| Up to 200 people | $15,000 |
14+
| More than 200 people | $20,000 |
1415

1516

1617
## 📝 Instructions:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
user_input = int(input('How many people are coming to your wedding?\n'))
2+
3+
if user_input <= 50:
4+
price = 4000
5+
elif user_input <= 100:
6+
price = 10000
7+
elif user_input <= 200:
8+
price = 15000
9+
else:
10+
price = 20000
11+
12+
print('Your wedding will cost '+str(price)+' dollars')

bc.json learn.json

File renamed without changes.

0 commit comments

Comments
 (0)