Skip to content

Commit 863093f

Browse files
committed
completed 03-04-07 and fixed issues
1 parent b7b45a8 commit 863093f

File tree

7 files changed

+62
-38
lines changed

7 files changed

+62
-38
lines changed

exercises/03-Print-Variables-In-The-Console/test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@
44

55
# from app import my_function
66
import pytest
7+
import app
8+
import os
79

8-
@pytest.mark.it('Your code needs to print hello on the console')
10+
@pytest.mark.it("1. You should create a variable named color")
11+
def test_use_forLoop():
12+
13+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
14+
content = f.read()
15+
assert content.find("color") > 0
16+
@pytest.mark.it('2. You should print on the console the value red ')
917
def test_for_file_output(capsys):
1018
captured = buffer.getvalue()
11-
assert captured == "hello\n" #add \n because the console jumps the line on every print
12-
19+
assert captured == "red\n" #add \n because the console jumps the line on every print
1320
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
1421
# def test_for_function_output(capsys):
1522
# my_function()

exercises/04-Multiply-Two-Values/test.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
# from app import my_function
66
import pytest
7+
import os
8+
import app
79

8-
@pytest.mark.it('Your code needs to print hello on the console')
9-
def test_for_file_output(capsys):
10-
captured = buffer.getvalue()
11-
assert captured == "hello\n" #add \n because the console jumps the line on every print
10+
@pytest.mark.it('1. You should create a variable named variables_are_cool')
11+
def test_use_variable_name():
1212

13-
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
14-
# def test_for_function_output(capsys):
15-
# my_function()
16-
# captured = capsys.readouterr()
17-
# assert captured.out == "Hello Inside Function\n"
13+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
14+
content = f.read()
15+
assert content.find("variables_are_cool") > 0
1816

19-
# @pytest.mark.it('Your function needs to return True')
20-
# def test_for_function_return(capsys):
21-
# assert my_function() == True
17+
@pytest.mark.it('2. You should print on the console the variables_are_cool value ')
18+
def test_for_file_output(capsys):
19+
my_result = 2345 *7323
20+
captured = buffer.getvalue()
21+
assert captured == str(my_result)+'\n'

exercises/06-Constants/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Since 2015, Javascript also allows the usage of constants, they differ from vari
44

55
To declare a constant, you have to use the reserved word **const** instead of **var**, like this:
66

7-
```Javascript
8-
const VERSION = '1.2';
7+
```py
8+
VERSION = '1.2'
99
```
1010

1111
Constants are super useful because some times, as a developer, you want to make sure parts of your data are read-only.

exercises/06-Constants/app.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
VERSION = '0.1';
2+
3+
VERSION = '0.9';
4+
5+
print(VERSION);
Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
# `07` String Concatenation
22

3-
One of Javascript's main objectives is to generate HTML code; concatenation comes in handy
4-
because you can create and add to existing HTML strings. To concatenate strings, we use
5-
the + (plus) operator, for example:
6-
7-
```Javascript
8-
var one = 'a';
9-
var two = 'b';
10-
console.log(one+two); //this will print 'ab' on the console.
3+
One common task you’ll need to accomplish with any language involves merging or combining strings.
4+
This process is referred to as concatenation.
5+
The best way to describe it is when you take two separate strings – stored by the interpreter – and
6+
merge them so that they become one.
7+
8+
```py
9+
one = 'a'
10+
two = 'b'
11+
print(one+two); #this will print 'ab' on the console.
1112
```
1213

13-
Constants are super useful because some times, as a developer, you want to make sure parts of your data are read-only.
14-
1514

1615
## 📝 Instructions:
1716

18-
1. Set the values for myVar1 and myVar2 so the code prints 'Hello World' in the console.
17+
1. Set the values for my_var1 and my_var2 so the code prints 'Hello World' in the console.
1918

2019

21-
## 💡 Hint:
2220

23-
Here is a 2min video explaining how to concatenate strings and what are they useful for.
24-
https://www.youtube.com/watch?v=cExgK0AnCdM
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
//Set the values here
1+
# Set the values here
2+
my_var1 = 'Hello'
3+
my_var2 = 'World'
24

35

46

5-
6-
//Don't change any of this line
7-
var theNewString = myVar1+' '+myVar2
8-
console.log(theNewString)
7+
## Don't change any of this line
8+
the_new_string = my_var1+' '+my_var2
9+
print(the_new_string)

exercises/07-String-Concatenation/test.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@
44

55
# from app import my_function
66
import pytest
7+
import app
8+
import os
79

8-
@pytest.mark.it('Your code needs to print hello on the console')
10+
11+
@pytest.mark.it("1. You should create a variable named my_var1")
12+
def test_use_my_var1():
13+
14+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
15+
content = f.read()
16+
assert content.find("my_var1") > 0
17+
@pytest.mark.it("2. You should create a variable named my_var2")
18+
def test_use_my_var2():
19+
20+
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
21+
content = f.read()
22+
assert content.find("my_var2") > 0
23+
@pytest.mark.it('3. Your code needs to print Hello World on the console')
924
def test_for_file_output(capsys):
1025
captured = buffer.getvalue()
11-
assert captured == "hello\n" #add \n because the console jumps the line on every print
26+
assert captured == "Hello World\n" #add \n because the console jumps the line on every print
1227

1328
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
1429
# def test_for_function_output(capsys):

0 commit comments

Comments
 (0)