From 7398da2e914427bcd6fbc2c15cba9d05b9ffa1b2 Mon Sep 17 00:00:00 2001 From: Adrian Garrido Date: Fri, 29 Apr 2022 09:25:02 +0200 Subject: [PATCH 1/5] Updated readme for this exercise --- README.md | 86 ++++++++++++------------------------------------------- 1 file changed, 19 insertions(+), 67 deletions(-) diff --git a/README.md b/README.md index 6aedb72..de5472c 100644 --- a/README.md +++ b/README.md @@ -1,81 +1,33 @@ -# Python teach and learn +# 0_hello-world -This is a repository to teach and learn Python. +The main topic of this branch is to practice with GitHub. -If you are a teacher, you can use all the exercises on this repo for your own purpose: -teach some concept, exams, etc. - -As a student take a look to the explanations below. - -## Requirements - -* Python >= 3.6. -* Git installed. -* A GitHub account. - -## Repo structure - -On master you only have a few files, every exercise is inside his own branch. - -Every branch has a name with index + what we learn. -For example the first branch is `0_hello-world`. -Also, we have modifications to the main exercise on a branch, example: `0.1_hello-someone`. -This modifications add more complexity to the main problem like is usually done on [code katas](https://en.wikipedia.org/wiki/Kata#Outside_martial_arts). - -> Katas starts with a simple problem and will be more complicated on every step - -## Step by step guide - -If you fork this repo, never update the original branches because you could have conflicts in the future. Instead of that, create new branches. - -### Step 0: Read it - -Yes, this should be your first step, read this README and, of course, we start with 0 not 1. -If you do not know why, we will see it in the future, be patient. - -### Step 1: Fork - -You should fork this repo and then start working with it. -How? We will see a step by step guide with git commands. - -If you use another tool like GitHub Desktop take a look to their docs. - -![fork button](docs/images/fork-btn.jpg) - -### Step 2: Setup the upstream - -This step is required to have the latests updates from the main repo in your forked one. - -When you setup this you will be able to: - -1. Update the master branch of your forked repo. -2. Get any new branch created from the main repo. - -#### Add upstream remote origin +## Create your own branch ```shell -git remote add upstream git@github.com:mrroot5/python-teach-learn.git +git checkout -b 0_hello-world_jhon-doe ``` -#### Update branches +## Tips -This could be done with the fetch button on GitHub: +If you use **VSCode** I recommend you this extensions: -![fetch button](docs/images/fetch-upstream-btn.jpg) +> **Name:** markdownlint. +**Description:** Markdown linting and style checking for Visual Studio Code. +**VS Marketplace Link:** -Or with a git command: +> **Name:** Python. +**Description:** IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. +**VS Marketplace Link:** -```shell -git pull upstream master -``` +> **Name:** Pylance. +**Description:** A performant, feature-rich language server for Python in VS Code. +**VS Marketplace Link:** -Simply change master for the branch you want. -On GitHub you must change to a new branch to have the option to fetch it. +My favorite IDE is **PyCharm** but VSCode is a very good option too. -#### Update list of branches +## Start coding -I do not know if GitHub have an option to do this so, this is the command: +The objective of this exercise is to print a "hello world" on your terminal. -```shell -git fetch upstream -``` +If you want to test your code to know if it works, use `python3 test.py`. From a88331e0b156e9f3cace496fda6ab8e008b898cb Mon Sep 17 00:00:00 2001 From: Adrian Garrido Date: Fri, 29 Apr 2022 09:25:21 +0200 Subject: [PATCH 2/5] Added main and tests --- main.py | 8 ++++++++ test.py | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 main.py create mode 100644 test.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..75b18a5 --- /dev/null +++ b/main.py @@ -0,0 +1,8 @@ +# Import modules if required + +# Create functions or classes to accomplish your task + +if __name__ == '__main__': + # Do here the main things to accomplish your task + # For example: call functions to process an input data + pass # this could be removed diff --git a/test.py b/test.py new file mode 100644 index 0000000..ded0eca --- /dev/null +++ b/test.py @@ -0,0 +1,23 @@ +import unittest + +from subprocess import Popen, PIPE +from os import linesep + + +class HelloWorldTestCase(unittest.TestCase): + def print_hello_world(self): + linesep_bytes = linesep.encode("utf8") + possible_values = [ + b'hello world' + linesep_bytes, + b'hello world!' + linesep_bytes, + b'Hello World' + linesep_bytes, + b'Hello World!' + linesep_bytes + ] + cmd = "python3 main.py" + proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE) + (output, error) = proc.communicate() + self.assertIn(output, possible_values) + + +if __name__ == '__main__': + unittest.main() From 71dc7744d24351b49916117b01323569fb963250 Mon Sep 17 00:00:00 2001 From: Adrian Garrido Date: Sat, 30 Apr 2022 10:02:21 +0200 Subject: [PATCH 3/5] Added exercise explanation --- README.md | 28 +++++++--------------------- test.py | 23 ----------------------- 2 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 test.py diff --git a/README.md b/README.md index de5472c..d44fb6a 100644 --- a/README.md +++ b/README.md @@ -5,29 +5,15 @@ The main topic of this branch is to practice with GitHub. ## Create your own branch ```shell -git checkout -b 0_hello-world_jhon-doe +git checkout -b 0.1_hello-world_jhon-doe ``` -## Tips - -If you use **VSCode** I recommend you this extensions: - -> **Name:** markdownlint. -**Description:** Markdown linting and style checking for Visual Studio Code. -**VS Marketplace Link:** - -> **Name:** Python. -**Description:** IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting, refactoring, unit tests, and more. -**VS Marketplace Link:** - -> **Name:** Pylance. -**Description:** A performant, feature-rich language server for Python in VS Code. -**VS Marketplace Link:** - -My favorite IDE is **PyCharm** but VSCode is a very good option too. - ## Start coding -The objective of this exercise is to print a "hello world" on your terminal. +The objective of this exercise is to print a "Hello {something}" on your terminal. + +You must receive an input from the user and print the word "Hello" with the user input. +For example: -If you want to test your code to know if it works, use `python3 test.py`. +If the user introduces `Peter` then you should print `Hello Peter`. +It does not matter if the user introduces a string, int, etc, just print it. diff --git a/test.py b/test.py deleted file mode 100644 index ded0eca..0000000 --- a/test.py +++ /dev/null @@ -1,23 +0,0 @@ -import unittest - -from subprocess import Popen, PIPE -from os import linesep - - -class HelloWorldTestCase(unittest.TestCase): - def print_hello_world(self): - linesep_bytes = linesep.encode("utf8") - possible_values = [ - b'hello world' + linesep_bytes, - b'hello world!' + linesep_bytes, - b'Hello World' + linesep_bytes, - b'Hello World!' + linesep_bytes - ] - cmd = "python3 main.py" - proc = Popen(cmd.split(' '), stdout=PIPE, stderr=PIPE) - (output, error) = proc.communicate() - self.assertIn(output, possible_values) - - -if __name__ == '__main__': - unittest.main() From 04b40107f4ea691979a7646403f59c6c7dd4e5b6 Mon Sep 17 00:00:00 2001 From: Adrian Garrido Date: Sat, 30 Apr 2022 10:09:21 +0200 Subject: [PATCH 4/5] Updated exercise --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d44fb6a..bddd7a6 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,19 @@ -# 0_hello-world +# 0.2_hello-world The main topic of this branch is to practice with GitHub. ## Create your own branch ```shell -git checkout -b 0.1_hello-world_jhon-doe +git checkout -b 0.2_hello-world_jhon-doe ``` ## Start coding The objective of this exercise is to print a "Hello {something}" on your terminal. -You must receive an input from the user and print the word "Hello" with the user input. +You must receive an argument and print the word "Hello" with the argument value. For example: -If the user introduces `Peter` then you should print `Hello Peter`. +If the script is executed with the value `Peter` then you should print `Hello Peter`. It does not matter if the user introduces a string, int, etc, just print it. From 8c7f779ae3227762049a50e2125a7907ae27f348 Mon Sep 17 00:00:00 2001 From: Adrian Garrido Date: Sat, 30 Apr 2022 10:12:09 +0200 Subject: [PATCH 5/5] Updated exercise objetive --- README.md | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index bddd7a6..66d3c77 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,14 @@ -# 0.2_hello-world +# 0.2.1_hello-world The main topic of this branch is to practice with GitHub. ## Create your own branch ```shell -git checkout -b 0.2_hello-world_jhon-doe +git checkout -b 0.2.1_hello-world_jhon-doe ``` ## Start coding -The objective of this exercise is to print a "Hello {something}" on your terminal. - -You must receive an argument and print the word "Hello" with the argument value. -For example: - -If the script is executed with the value `Peter` then you should print `Hello Peter`. -It does not matter if the user introduces a string, int, etc, just print it. +From the version 0.2 now allow only string as user input, of course, if the user introduces an int +or other not allowed value, show a message explaining the error and how to use this script.