Skip to content
Open
Changes from all commits
Commits
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
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Playground and Cheatsheet for Learning Python

> 🇺🇦 UKRAINE [IS BEING ATTACKED](https://war.ukraine.ua/) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED.
> 🇺🇦 UKRAINE [IS BEING ATTACKED](https://war.ukraine.ua/) BY THE RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED.
> - Help Ukraine via:
> - [Serhiy Prytula Charity Foundation](https://prytulafoundation.org/en/)
> - [Come Back Alive Charity Foundation](https://savelife.in.ua/en/donate-en/)
Expand Down Expand Up @@ -34,6 +34,7 @@ without launching them.
Each Python script in this repository has the following structure:

```python

"""Lists <--- Name of the topic here

# @see: https://www.learnpython.org/en/Lists <-- Link to further readings goes here
Expand All @@ -50,12 +51,20 @@ def test_list_type():

# Here is an example of how to build a list. <-- Comments here explain the action
squares = [1, 4, 9, 16, 25]
cubes = [1, 8, 27, 64, 125]

# Lists can be indexed and sliced.
# Lists can be indexed, sliced and even merged.

# Indexing returns the item.
assert squares[0] == 1 # <-- Assertions here illustrate the result.

# Slicing returns a new list.
assert squares[-3:] == [9, 16, 25] # <-- Assertions here illustrate the result.

# Merging returns a new combined list.
merged = squares + cubes
assert merged == [1, 4, 9, 16, 25, 1, 8, 27, 64, 125]

```

So normally you might want to do the following:
Expand All @@ -65,7 +74,7 @@ So normally you might want to do the following:
- Look at code examples and assertions to see usage examples and expected output.
- Change code or add new assertions to see how things work.
- [Run tests](#testing-the-code) and [lint the code](#linting-the-code) to see if it work and is
written correctly.
written correctly.

## Table of Contents

Expand Down Expand Up @@ -155,7 +164,9 @@ by running `pip` or `pip3`.
You may check your Python version by running:

```bash

python --version

```

Note that in this repository whenever you see `python` it will be assumed that it is Python **3**.
Expand All @@ -165,7 +176,9 @@ Note that in this repository whenever you see `python` it will be assumed that i
Install all dependencies that are required for the project by running:

```bash

pip install -r requirements.txt

```

## Testing the Code
Expand All @@ -178,13 +191,17 @@ You may add new tests for yourself by adding files and functions with `test_` pr
To run all the tests please execute the following command from the project root folder:

```bash

pytest

```

To run specific tests please execute:

```bash

pytest ./path/to/the/test_file.py

```

## Linting the Code
Expand All @@ -197,14 +214,18 @@ To check if the code is written with respect
to [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide please run:

```bash

pylint ./src/

```

In case if linter will detect error (i.e. `missing-docstring`) you may want to read more about
specific error by running:

```bash

pylint --help-msg=missing-docstring

```

[More about PyLint](http://pylint.pycqa.org/)
Expand All @@ -215,13 +236,17 @@ To check if the code is written with respect
to [PEP 8](https://www.python.org/dev/peps/pep-0008/) style guide please run:

```bash

flake8 ./src

```

Or if you want to have more detailed output you may run:

```bash

flake8 ./src --statistics --show-source --count

```

[More about Flake8](http://flake8.pycqa.org/en/latest/)
Expand Down