📜 ⬆️ ⬇️

Sandbox and Python Learning Cheat Sheet

I started learning Python3 with 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 on my own, 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 for loop, etc. in Python. 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 the tests to verify its correctness (using assertion . 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 punctuated with assertion users, 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). """ def test_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.

')

Source: https://habr.com/ru/post/421701/


All Articles