Sandbox and Python Learning Cheat Sheet

    I started learning Python3 with the documentation on the official site. I liked the code samples, but unfortunately they were not interactive there. I wanted to try to execute the code myself, with different inputs and look at the output. It is also easier for me personally to remember the constructions of a language, if I typed them several times manually. Python console for this is great, but I also wanted to have a kind of cheat sheet, which I could return to when writing programs in the future, if, for example, a question arises how to write a cycle in Python, foretc. And the last straw was the desire to automatically check the style of writing code in accordance with existing standards.. It was too lazy to read and delve into them, so I wanted to check the code automatically and tell me what mistakes I was making and how to fix them.


    As a result, I poured all my experiments on GitHub .



    The repository is a collection of Python scripts , divided into categories . Each script contains code samples, with comments and usage examples, as well as with links for further more detailed reading and study of each topic.


    As a result, the repository turned out to be a sandbox because users have the opportunity to change or add code, look at how it works and use tests to check its correctness (using assertion-y. It is also possible to check the code compliance with modern standards . Together, this should help users learn the language more interactively and from the very beginning maintain a good purity of the code.


    The repository also, in my opinion, is a cheat sheet in the sense that you can return to it and recall the basic constructs of the language , methods of objects, and the like. Also, due to the fact that the code is stuffed with assertionthem, users can check the expected result of the functions without starting them.


    How to use this repository


    Each Python script in the repository has the following structure:


    """Lists  <--- Название раскрываемого топика
    # @see: https://www.learnpython.org/en/Lists  <-- Ссылка для дальнейшего изучения
    И здесь могут идти общие детали, относящиеся к топику (например что-то про Lists).
    """deftest_list_type():"""Здесь идет название под-раздела (например "Создание списков" или "Методы списков").
        И более детальное описание подраздела...
        """# Here is an example of how to build a list.  <-- Комментарии, объясняющие код
        squares = [1, 4, 9, 16, 25]
        # Lists can be indexed and sliced. # Indexing returns the item.assert squares[0] == 1# <-- Assertion, иллюстрирующий результат выполнения кода.# Slicing returns a new list.assert squares[-3:] == [9, 16, 25]  # <-- Assertion, иллюстрирующий результат выполнения кода.

    Therefore, the process of using the repository may be as follows:



    Repository sections


    1. Getting Started
    2. Operators
    3. Data types
    4. Control flow
    5. Functions
    6. Classes
    7. Modules
    8. Errors and Exceptions
    9. Files
    10. Additions
    11. Brief Tour of the Standard Libraries

    I hope you find this repository useful.

    Also popular now: