Skip to content

Commit 8f5b301

Browse files
committed
done until exercise 06
1 parent 6b3f8e9 commit 8f5b301

File tree

19 files changed

+160
-105
lines changed

19 files changed

+160
-105
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# your code here
2+
print("Hello World")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def sum(number1,number2):
2+
return number1 + number2
3+
4+
total = sum(2,3)
5+
print(total)
6+
7+
8+
9+
10+
11+
12+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def calculate_area(length,edge):
2+
return length * edge
3+
4+
# Your code Below this line:

.gitpod.Dockerfile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
31
FROM gitpod/workspace-full:latest
4-
52
USER gitpod
6-
73
RUN pip3 install pytest pytest-testdox mock && npm i [email protected] -g

.gitpod.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ image:
33

44
ports:
55
- port: 3000
6-
onOpen: open-prerview
6+
onOpen: open-preview
77
tasks:
8-
- command: >
9-
bc run;
8+
- command: bc run
109
github:
1110
prebuilds:
1211
# enable for the master/default branch (defaults to true)

bc.json

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,52 +21,82 @@
2121
{
2222
"slug": "01-hello-world",
2323
"title": "01-hello-world",
24-
"path": "exercises/01-hello-world"
24+
"path": "exercises/01-hello-world",
25+
"translations": [
26+
"us"
27+
]
2528
},
2629
{
2730
"slug": "02-Hello-World",
2831
"title": "02-Hello-World",
29-
"path": "exercises/02-Hello-World"
32+
"path": "exercises/02-Hello-World",
33+
"translations": [
34+
"us"
35+
]
3036
},
3137
{
3238
"slug": "03-What-is-a-function",
3339
"title": "03-What-is-a-function",
34-
"path": "exercises/03-What-is-a-function"
40+
"path": "exercises/03-What-is-a-function",
41+
"translations": [
42+
"us"
43+
]
3544
},
3645
{
3746
"slug": "04-Call-a-function",
3847
"title": "04-Call-a-function",
39-
"path": "exercises/04-Call-a-function"
48+
"path": "exercises/04-Call-a-function",
49+
"translations": [
50+
"us"
51+
]
4052
},
4153
{
4254
"slug": "05-Defining-vs-Calling-a-function",
4355
"title": "05-Defining-vs-Calling-a-function",
44-
"path": "exercises/05-Defining-vs-Calling-a-function"
56+
"path": "exercises/05-Defining-vs-Calling-a-function",
57+
"translations": [
58+
"us"
59+
]
4560
},
4661
{
4762
"slug": "06-Anonymous-functions",
4863
"title": "06-Anonymous-functions",
49-
"path": "exercises/06-Anonymous-functions"
64+
"path": "exercises/06-Anonymous-functions",
65+
"translations": [
66+
"us"
67+
]
5068
},
5169
{
5270
"slug": "07-Arrow-Functions",
5371
"title": "07-Arrow-Functions",
54-
"path": "exercises/07-Arrow-Functions"
72+
"path": "exercises/07-Arrow-Functions",
73+
"translations": [
74+
"us"
75+
]
5576
},
5677
{
5778
"slug": "08-Function-that-returns",
5879
"title": "08-Function-that-returns",
59-
"path": "exercises/08-Function-that-returns"
80+
"path": "exercises/08-Function-that-returns",
81+
"translations": [
82+
"us"
83+
]
6084
},
6185
{
6286
"slug": "09-Function-parameters",
6387
"title": "09-Function-parameters",
64-
"path": "exercises/09-Function-parameters"
88+
"path": "exercises/09-Function-parameters",
89+
"translations": [
90+
"us"
91+
]
6592
},
6693
{
6794
"slug": "10-Array-Methods",
6895
"title": "10-Array-Methods",
69-
"path": "exercises/10-Array-Methods"
96+
"path": "exercises/10-Array-Methods",
97+
"translations": [
98+
"us"
99+
]
70100
}
71101
]
72102
}

exercises/02-Hello-World/app.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
# your code here
2-
print("Hello World")
1+
# your code here

exercises/02-Hello-World/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def test_output():
66
content = f.read()
77
assert content.find("print(") > 0
88

9-
@pytest.mark.it('3. The printed value on the console should be "red"')
9+
@pytest.mark.it('The printed value on the console should be "red"')
1010
def test_for_file_output(capsys, app):
1111
app()
1212
captured = capsys.readouterr()

exercises/05-Defining-vs-Calling-a-function/README.md

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,40 @@ Functions will only exists if you or somebody else defines them... is the only w
44

55
To define a function we need to write this basic code formula:
66

7-
```js
8-
function myFunctionName(parameter, parameter2,... parameterX){
9-
//the function code here
7+
```python
8+
def myFunctionName(parameter, parameter2, ...parameterX):
9+
# the function code here
1010
return something
11-
}
1211
```
1312

14-
The word `function` is a reserved word in javascript, this means it is only used to define a function.
13+
The word `def` is a reserved word in Python, this means it is only used to define a function.
1514

16-
**The name** of the function could be anything you like. Tip: use a descriptive name (don't be cheap with words, use as many as you need) this way you will understand what the function does -and returns-.
17-
Example names: addTwoIntegers , convertAStringIntoAnInteger , changeTheWorldUsingFrontEndDevelopment
15+
**The name** of the function could be anything you like.
16+
Tip: use a descriptive name (don't be cheap with words,
17+
use as many as you need) this way you will understand what the function
18+
does -and returns-.
19+
Example names: add_two_integers , calculate_taxes , get_random_number, etc.
1820

19-
**Parameters:** you can define as many parameters as you like, nay, need. The amount of parameters will depend on the operations done inside the function, I.E: if the function is adding two integers (3 + 4) this means the function will need two parameters (one for each integer).
21+
**Parameters:** you can define as many parameters as you like or need.
22+
The amount of parameters will depend on the operations done inside the function,
23+
I.E: if the function is adding two integers `(3 + 4)` this means the function
24+
will need two parameters (one for each integer).
2025

21-
**Scope:** All the operations that the function will do needs to be inside the `{` `}` (curly brackets), anything outside won't be considered as part of the function, this is called **the scope**, and it could be local (inside the function) and global (outside of the function).
26+
**Scope:** All the code that the function will contain need to be indented
27+
one tab to the right, anything on a different indentation
28+
won't be considered as part of the function,
29+
this is called **the scope**, and it could be local (inside the function)
30+
and global (outside of the function).
2231

2332
**The Return**: not every function needs to return something, but it is recommended that it does.
24-
Tip: return is a good default for when you, still, doesn't know if you need to return something.
33+
Tip: returning `None` is a good default for when you, still, doesn't know if you need to return something.
2534

2635
Example of a function:
2736

28-
```js
29-
function concatenateNumberToString(localNumber, localString){
30-
let localVariable = localString+""+localNumber
31-
return localVariable
32-
}
37+
```python
38+
def concatenate_number_to_string(local_number, local_string):
39+
local_variable = local_string+""+str(local_number)
40+
return local_variable
3341
```
3442

3543

@@ -42,4 +50,3 @@ function concatenateNumberToString(localNumber, localString){
4250
# 💡 Hint
4351

4452
Remember to add the "return" line, every function must return something, in this case it should be the result of the multiplication.
45-
Don't forget the semi colon!

0 commit comments

Comments
 (0)