Skip to content

Completed Test #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 88 commits into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
906fbcf
initialized project and exercise 01
plucodev Sep 18, 2019
f3e1eda
initialized exercise 02
plucodev Sep 18, 2019
aa0b223
initialized exercise 03
plucodev Sep 18, 2019
cba4e25
initialized exercise 04
plucodev Sep 18, 2019
4ca3ef5
initialized exercise 05
plucodev Sep 18, 2019
666c6ce
initialized exercise 06
plucodev Sep 18, 2019
cccf689
initialized exercise 07
plucodev Sep 18, 2019
4806ba1
initialized exercise 08
plucodev Sep 18, 2019
dde938a
initialized exercise 09
plucodev Sep 18, 2019
76b27dc
initialized exercise 10
plucodev Sep 18, 2019
d772cfe
initialized exercise 11
plucodev Sep 18, 2019
7d3f565
initialized exercise 12
plucodev Sep 18, 2019
8764cbb
initialized exercise 13
plucodev Sep 18, 2019
271cca9
initialized exercise 14
plucodev Sep 18, 2019
8856354
initialized exercise 15
plucodev Sep 18, 2019
1eb01f5
initialized exercise 16
plucodev Sep 18, 2019
7244acd
initialized exercise 17
plucodev Sep 18, 2019
70bada7
initialized exercise 18
plucodev Sep 18, 2019
1502e98
initialized exercise 19
plucodev Sep 18, 2019
cd664d4
initialized exercise 20
plucodev Sep 18, 2019
e843f35
initialized exercise 21
plucodev Sep 18, 2019
ab4ddd5
initialized exercise 22
plucodev Sep 18, 2019
a059306
initialized exercise 23
plucodev Sep 18, 2019
63dc9ae
initialized exercise 24
plucodev Sep 18, 2019
3c319f3
initialized exercise 25
plucodev Sep 18, 2019
04db4e3
updated README 01 for Python
plucodev Sep 18, 2019
7830642
updated README 02 for Python
plucodev Sep 18, 2019
96c1a7f
fixed issues
plucodev Sep 18, 2019
199048f
completed 01
plucodev Sep 18, 2019
2331eb7
completed 01
plucodev Sep 18, 2019
b7b45a8
completed 02
plucodev Sep 18, 2019
863093f
completed 03-04-07 and fixed issues
plucodev Sep 18, 2019
494baf0
fixed issues 07
plucodev Sep 18, 2019
67d5020
completed 08
plucodev Sep 19, 2019
6780d10
fixed issues 08
plucodev Sep 19, 2019
f663440
updated 00
plucodev Sep 20, 2019
9935509
updated 05
plucodev Sep 24, 2019
6521ffa
updated 09
plucodev Sep 24, 2019
40c3e55
updated 10
plucodev Sep 24, 2019
6eec555
updated 11
plucodev Sep 24, 2019
c5b19f3
updated 12
plucodev Sep 24, 2019
14e0788
updated 13
plucodev Sep 25, 2019
ecaaa72
updated 13 and 14
plucodev Sep 25, 2019
6f79798
updated 17
plucodev Sep 25, 2019
ddbbdc8
updated 15
plucodev Sep 26, 2019
544913e
updated 16
plucodev Sep 26, 2019
17448f5
updated 13
plucodev Sep 26, 2019
5d7c381
updated 14
plucodev Sep 26, 2019
c88878a
updated 18
plucodev Sep 26, 2019
790bff9
updated 20
plucodev Sep 26, 2019
7a74ef8
updated 21
plucodev Sep 26, 2019
640bd6f
updated 12
plucodev Sep 26, 2019
4698f63
updated 21
plucodev Sep 26, 2019
5fe14a6
updated 22
plucodev Sep 26, 2019
c7fe498
updated 23
plucodev Sep 26, 2019
0feaf3f
updated 24
plucodev Sep 27, 2019
e4d881c
updated 25
plucodev Sep 27, 2019
69336d0
updated 25
plucodev Sep 27, 2019
79757da
updated 24
plucodev Sep 27, 2019
59eba4b
updated 23
plucodev Sep 27, 2019
8d2d02b
updated 21
plucodev Sep 27, 2019
ee9965f
updated 20
plucodev Sep 27, 2019
3f42207
updated 22
plucodev Sep 30, 2019
6946622
fixed issues 01-02-03-13
plucodev Oct 2, 2019
62db4c9
fixed issues 04
plucodev Oct 2, 2019
8cafcd7
fixed issues 05
plucodev Oct 2, 2019
7da8203
fixed issues 07
plucodev Oct 2, 2019
71d4172
fixed issues 08
plucodev Oct 2, 2019
a9520e7
fixed issues 09
plucodev Oct 2, 2019
5255d84
fixed issues 10
plucodev Oct 2, 2019
211f128
fixed issues 11
plucodev Oct 2, 2019
2e0bc06
fixed issues 12
plucodev Oct 2, 2019
e0d5a2a
fixed issues 12
plucodev Oct 2, 2019
1742933
fixed issues 13
plucodev Oct 2, 2019
ee37430
fixed issues 14-15-16
plucodev Oct 2, 2019
38d4e0e
fixed issues 17-18-19
plucodev Oct 4, 2019
0fb467b
fixed issues 21
plucodev Oct 4, 2019
f51d6be
fixed issues 22
plucodev Oct 4, 2019
f980101
fixed issues 23
plucodev Oct 4, 2019
e29047e
fixed issues 24 - 25
plucodev Oct 5, 2019
537d4e7
fixed issues 01 - 02
plucodev Oct 5, 2019
9dc7c9b
fixed issues 03
plucodev Oct 7, 2019
c9b5dc2
fixed issues 04
plucodev Oct 7, 2019
1fa2128
fixed issues 05
plucodev Oct 7, 2019
187af9f
deleted constant exercise
plucodev Oct 7, 2019
8500ea0
fixed genaral issues
plucodev Oct 7, 2019
98144e7
fixed issues 07-08-09-17-18
plucodev Oct 7, 2019
4d3d877
deleted 26
plucodev Oct 7, 2019
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
24 changes: 24 additions & 0 deletions exercises/00-Welcome/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Welcome to Python Beginner Course!!

We are very excited to have you here !! 🎉 😂

During this course you will be learning the following concepts:

1. How to create and call functions.
2. How to create and call variables.
3. How to concatenate strings.
4. How to use loops and if statements.
5. How to combine and use all these concepts.



## Contributors

Thanks goes to these wonderful people ([emoji key](https://github.com/kentcdodds/all-contributors#emoji-key)):

1. [Alejandro Sanchez (alesanchezr)](https://github.com/alesanchezr), contribution: (coder) :computer: (idea) 🤔, (build-tests) :warning:, (pull-request-review) :eyes: (build-tutorial) :white_check_mark: (documentation) :book:
1. [Paolo Lucano (plucodev)](https://github.com/plucodev), contribution: (coder), (build-tests) :warning:

This project follows the
[all-contributors](https://github.com/kentcdodds/all-contributors)
specification. Contributions of any kind are welcome!
16 changes: 16 additions & 0 deletions exercises/01-Console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# `01` Console

In Python, we use **print** to make the computer write anything we want (the content of a variable, a given string, etc.) in something called "the console".

Every language has a console, as it was the only way to interact with the users at the beginning (before the Windows or MacOS arrived).
Today, printing in the console is used mostly as a monitoring tool, ideal to leave a trace of the content of variables during the program execution.

This is an example of how to use it:
```py
print("How are you?")
```

## 📝 Instructions:

1. Use **print** to print "Hello World" on the console. Feel free to try other things as well.

1 change: 1 addition & 0 deletions exercises/01-Console/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 21 additions & 0 deletions exercises/01-Console/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import io
import sys
sys.stdout = buffer = io.StringIO()
import app
import re
import os
import pytest

@pytest.mark.it('1. Your code needs to print Hello World! on the console')
def test_for_file_output(capsys):
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
my_print = [s for s in content if "print" in s]
my_printIndex = content.index(my_print[0])
# print(my_print_index)
regex = r"print\(\"Hello World!\"\)"
assert re.match(regex, content[my_printIndex])
captured = buffer.getvalue()
assert captured == "Hello World!\n" #add \n because the console jumps the line on every print

1 change: 0 additions & 1 deletion exercises/01-welcome/README.md

This file was deleted.

15 changes: 15 additions & 0 deletions exercises/02-Declare-Variables/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `02` Declare Variables

Variables act as a box (container) that lets you store different types of data. This is how we set a variable:
```py
name = "Daniel"
```

## 📝 Instructions:

1. Declare a new variable with the string value "Yellow" and print the value to the console.


## 💡 Hint:

The name of the variable can be whatever you want, but the value inside has to be the string "Yellow".
Empty file.
37 changes: 37 additions & 0 deletions exercises/02-Declare-Variables/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import io
import sys
sys.stdout = buffer = io.StringIO()
import app
# from app import my_function
import pytest
import os
import re

# @pytest.mark.it('1. Declare a variable with a string value "Yellow" ')
# def test_for_regex(capsys):
# f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
# content = f.readlines()
# content = [x.strip() for x in content]

# # variable = 'name = "Yellow"'
# variable = r"\w(\s*)=(\s*)\"Yellow\""
# assert re.match(variable, content[0])

@pytest.mark.it('1. Your code needs to print Yellow on the console')
def test_for_file_output(capsys):
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
my_var = [s for s in content if "print" in s]
my_varIndex = content.index(my_var[0])
# print(my_print_index)
regex_var = r"print(\s*)\(\w*\)"
assert re.match(regex_var, content[my_varIndex])
my_print = [s for s in content if "Yellow" in s]
my_printIndex = content.index(my_print[0])
# print(my_print_index)
regex = r"\w*(\s*)=(\s*)\"Yellow\""
assert re.match(regex, content[my_printIndex])
captured = buffer.getvalue()
assert captured == "Yellow\n" #add \n because the console jumps the line on every print

20 changes: 0 additions & 20 deletions exercises/02-hello-world/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions exercises/02-hello-world/app.py

This file was deleted.

21 changes: 0 additions & 21 deletions exercises/02-hello-world/test.py

This file was deleted.

13 changes: 13 additions & 0 deletions exercises/03-Print-Variables-In-The-Console/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `03` Print the Variables in the console

You can also use the **print** function to print variables in the console, it's a great way to know their content, like this:
```py
my_super_variable = 'hello'
print(my_super_variable)
```

## 📝 Instructions:

1. Declare a new variable called **color** and assign the value "red" to it.
2. Then, print its value on the console.

Empty file.
41 changes: 41 additions & 0 deletions exercises/03-Print-Variables-In-The-Console/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import io
import sys
sys.stdout = buffer = io.StringIO()

# from app import my_function
import pytest
import app
import os
import re

@pytest.mark.it("1. You should create a variable named color")
def test_use_forLoop():

f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]

# regex = r"color = \"red\""
regex = r"color(\s*)=(\s*)\"red\""
assert re.match(regex, content[0])
@pytest.mark.it('2. You should print on the console the value red ')
def test_for_file_output(capsys):
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
my_print = [s for s in content if "print" in s]
my_printIndex = content.index(my_print[0])
# print(my_print_index)
regex = r"print(\s*)\(color\)"
assert re.match(regex, content[my_printIndex])
captured = buffer.getvalue()
assert captured == "red\n" #add \n because the console jumps the line on every print
# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
# def test_for_function_output(capsys):
# my_function()
# captured = capsys.readouterr()
# assert captured.out == "Hello Inside Function\n"

# @pytest.mark.it('Your function needs to return True')
# def test_for_function_return(capsys):
# assert my_function() == True
18 changes: 18 additions & 0 deletions exercises/04-Multiply-Two-Values/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# `04` Multiply Two Values

Any programming language lets you do basic Math operations like multiplication, division, etc.

To multiply 2 values in python, you have to use the asterisk operator like this:
```py
resulting_value = 2 * 3
```
In this case, we stored the result value of the multiplication into a variable called **resulting_value**.

## 📝 Instructions:

1. Please store the result of multiplying 2345 times 7323 in a variable called **variables_are_cool**
2. Now print the result in the console.




Empty file.
36 changes: 36 additions & 0 deletions exercises/04-Multiply-Two-Values/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import io
import sys
sys.stdout = buffer = io.StringIO()

# from app import my_function
import pytest
import os
import app
import re

@pytest.mark.it('1. You should create a variable named variables_are_cool')
def test_use_variable_name():
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
regex = r"variables_are_cool(\s*)=(\s*)2345(\s*)\*(\s*)7323"
# regex = r"color = \"red\""
# regex = r"color(\s*)=(\s*)\"red\""
assert re.match(regex, content[0])

@pytest.mark.it('2. You should print on the console the variables_are_cool value ')
def test_for_file_output(capsys):
regex = r"print(\s*)\(variables_are_cool\)"
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
# indices = [i for i, s in enumerate(content) if 'print' in s]
# print(int(indices))
my_print = [s for s in content if "print" in s]
my_print_index = content.index(my_print[0])
print(my_print_index)
# print([s for s in content if "print" in s])
my_result = 2345 *7323
captured = buffer.getvalue()
assert captured == str(my_result)+'\n'
assert re.match(regex, content[my_print_index])
13 changes: 13 additions & 0 deletions exercises/05-User-Inputed-Values/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `05` User Inputed Values

The other cool thing about variables is that you don't need to know their value to be able to work with them.

For example, the application right now is prompting the user for its age, and then printing it on the console.

## 📝 Instructions:

1. Please add 10 years to the value of the age variable.

- The content of the variable its being previously filled with whatever the user inputs.


4 changes: 4 additions & 0 deletions exercises/05-User-Inputed-Values/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
age = int(input('What is your age?\n'))
# CHANGE THE CODE BELOW TO ADD 10 TO AGE

print("Your age is: "+str(age))
14 changes: 14 additions & 0 deletions exercises/05-User-Inputed-Values/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import pytest,os,re,io,sys, mock, json

@pytest.mark.it("1. You should print on the console the input value + 10")
def test_t(stdin):
_input = json.loads(stdin)
print("####", _input[0])
my_testString = int(_input[0]) + 10
print("$$$$$:",int(my_testString) + 10)
with mock.patch('builtins.input', lambda x: _input.pop()):
# f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
sys.stdout = buffer = io.StringIO()
import app
captured = buffer.getvalue()
assert captured == "Your age is: " + str(my_testString)+'\n'
20 changes: 20 additions & 0 deletions exercises/06-String-Concatenation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# `06` String Concatenation

One common task you’ll need to accomplish with any language involves merging or combining strings.
This process is referred to as concatenation.
The best way to describe it is when you take two separate strings – stored by the interpreter – and
merge them so that they become one.

```py
one = 'a'
two = 'b'
print(one+two); #this will print 'ab' on the console.
```


## 📝 Instructions:

1. Set the values for my_var1 and my_var2 so the code prints 'Hello World' in the console.



6 changes: 6 additions & 0 deletions exercises/06-String-Concatenation/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set the values here


## Don't change below this line
the_new_string = my_var1+' '+my_var2
print(the_new_string)
48 changes: 48 additions & 0 deletions exercises/06-String-Concatenation/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import io
import sys
sys.stdout = buffer = io.StringIO()

# from app import my_function
import pytest
import app
import os
import re


@pytest.mark.it("1. You should create a variable named my_var1")
def test_use_my_var1():
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
my_var1 = [s for s in content if "my_var1" in s]
my_var1Var = content.index(my_var1[0])
regex_my_var1 = r"my_var1(\s*)=(\s*)\"(\s*)Hello(\s*)\""
# regex = r"color = \"red\""
# regex = r"color(\s*)=(\s*)\"red\""
assert re.match(regex_my_var1, content[my_var1Var])
@pytest.mark.it("2. You should create a variable named my_var2")
def test_use_my_var2():
f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py')
content = f.readlines()
content = [x.strip() for x in content]
my_var2 = [s for s in content if "my_var2" in s]
my_var2Var = content.index(my_var2[0])
regex_my_var2 = r"my_var2(\s*)=(\s*)\"(\s*)World(\s*)\""
# regex = r"color = \"red\""
# regex = r"color(\s*)=(\s*)\"red\""
assert re.match(regex_my_var2, content[my_var2Var])
@pytest.mark.it('3. Your code needs to print Hello World on the console')
def test_for_file_output(capsys):

captured = buffer.getvalue()
assert captured == "Hello World\n" #add \n because the console jumps the line on every print

# @pytest.mark.it('Your function needs to print "Hello Inside Function" on the console')
# def test_for_function_output(capsys):
# my_function()
# captured = capsys.readouterr()
# assert captured.out == "Hello Inside Function\n"

# @pytest.mark.it('Your function needs to return True')
# def test_for_function_return(capsys):
# assert my_function() == True
Loading