[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2604":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":16,"starSnapshotCount":16,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},2604,"learn-python","trekhleb\u002Flearn-python","trekhleb","📚 Playground and cheatsheet for learning Python. Collection of Python scripts that are split by topics and contain code examples with explanations.","",null,"Python",18044,2955,716,17,0,5,27,98,20,45,"MIT License",false,"master",[26,27,28,29,30,31],"learning","learning-by-doing","learning-python","programming-language","python","python3","2026-06-12 02:00:42","# Playground and Cheatsheet for Learning Python\n\n> 🇺🇦 UKRAINE [IS BEING ATTACKED](https:\u002F\u002Fwar.ukraine.ua\u002F) BY RUSSIAN ARMY. CIVILIANS ARE GETTING KILLED. RESIDENTIAL AREAS ARE GETTING BOMBED.\n> - Help Ukraine via:\n>   - [Serhiy Prytula Charity Foundation](https:\u002F\u002Fprytulafoundation.org\u002Fen\u002F)\n>   - [Come Back Alive Charity Foundation](https:\u002F\u002Fsavelife.in.ua\u002Fen\u002Fdonate-en\u002F)\n>   - [National Bank of Ukraine](https:\u002F\u002Fbank.gov.ua\u002Fen\u002Fnews\u002Fall\u002Fnatsionalniy-bank-vidkriv-spetsrahunok-dlya-zboru-koshtiv-na-potrebi-armiyi)\n> - More info on [war.ukraine.ua](https:\u002F\u002Fwar.ukraine.ua\u002F) and [MFA of Ukraine](https:\u002F\u002Ftwitter.com\u002FMFA_Ukraine)\n\n\u003Chr\u002F>\n\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Ftrekhleb\u002Flearn-python.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Ftrekhleb\u002Flearn-python)\n\n> This is a collection of Python scripts that are split by [topics](#table-of-contents) and contain \ncode examples with explanations, different use cases and links to further readings.\n\n> _Read this in:_ [_Português_](README.pt-BR.md), [_Español_](README.es-ES.md), [_Traditional Chinese_](README.zh-TW.md), [_Українська_](README.uk-UA.md).\n\nIt is a **playground** because you may change or add the code to see how it works \nand [test it out](#testing-the-code) using assertions. It also allows you \nto [lint the code](#linting-the-code) you've wrote and check if it fits to Python code style guide.\nAltogether it might make your learning process to be more interactive and it might help you to keep \ncode quality pretty high from very beginning.\n\nIt is a **cheatsheet** because you may get back to these code examples once you want to recap the \nsyntax of [standard Python statements and constructions](#table-of-contents). Also because the \ncode is full of assertions you'll be able to see expected functions\u002Fstatements output right away\nwithout launching them.\n\n> _You might also be interested in 🤖 [Interactive Machine Learning Experiments](https:\u002F\u002Fgithub.com\u002Ftrekhleb\u002Fmachine-learning-experiments)_\n\n## How to Use This Repository\n\nEach Python script in this repository has the following structure:\n\n```python\n\"\"\"Lists  \u003C--- Name of the topic here\n\n# @see: https:\u002F\u002Fwww.learnpython.org\u002Fen\u002FLists  \u003C-- Link to further readings goes here\n\nHere might go more detailed explanation of the current topic (i.e. general info about Lists).\n\"\"\"\n\n\ndef test_list_type():\n    \"\"\"Explanation of sub-topic goes here.\n    \n    Each file contains test functions that illustrate sub-topics (i.e. lists type, lists methods).\n    \"\"\"\n    \n    # Here is an example of how to build a list.  \u003C-- Comments here explain the action\n    squares = [1, 4, 9, 16, 25]\n    \n    # Lists can be indexed and sliced. \n    # Indexing returns the item.\n    assert squares[0] == 1  # \u003C-- Assertions here illustrate the result.\n    # Slicing returns a new list.\n    assert squares[-3:] == [9, 16, 25]  # \u003C-- Assertions here illustrate the result.\n```\n\nSo normally you might want to do the following:\n\n- [Find the topic](#table-of-contents) you want to learn or recap.\n- Read comments and\u002For documentation that is linked in each script's docstring (as in example above). \n- Look at code examples and assertions to see usage examples and expected output.\n- Change code or add new assertions to see how things work.\n- [Run tests](#testing-the-code) and [lint the code](#linting-the-code) to see if it work and is \nwritten correctly.\n\n## Table of Contents\n\n1. **Getting Started**\n    - [What is Python](src\u002Fgetting_started\u002Fwhat_is_python.md)\n    - [Python Syntax](src\u002Fgetting_started\u002Fpython_syntax.md)\n    - [Variables](src\u002Fgetting_started\u002Ftest_variables.py)\n2. **Operators**\n    - [Arithmetic Operators](src\u002Foperators\u002Ftest_arithmetic.py) (`+`, `-`, `*`, `\u002F`, `\u002F\u002F`, `%`, `**`)\n    - [Bitwise Operators](src\u002Foperators\u002Ftest_bitwise.py) (`&`, `|`, `^`, `>>`, `\u003C\u003C`, `~`)\n    - [Assignment Operators](src\u002Foperators\u002Ftest_assigment.py) (`=`, `+=`, `-=`, `\u002F=`, `\u002F\u002F=` etc.)\n    - [Comparison Operator](src\u002Foperators\u002Ftest_comparison.py) (`==`, `!=`, `>`, `\u003C`, `>=`, `\u003C=`)\n    - [Logical Operators](src\u002Foperators\u002Ftest_logical.py) (`and`, `or`, `not`)\n    - [Identity Operators](src\u002Foperators\u002Ftest_identity.py) (`is`, `is not`)\n    - [Membership Operators](src\u002Foperators\u002Ftest_membership.py) (`in`, `not in`)\n3. **Data Types**\n    - [Numbers](src\u002Fdata_types\u002Ftest_numbers.py) (including booleans)\n    - [Strings](src\u002Fdata_types\u002Ftest_strings.py) and their methods\n    - [Lists](src\u002Fdata_types\u002Ftest_lists.py) and their methods (including list comprehensions)\n    - [Tuples](src\u002Fdata_types\u002Ftest_tuples.py)\n    - [Sets](src\u002Fdata_types\u002Ftest_sets.py) and their methods\n    - [Dictionaries](src\u002Fdata_types\u002Ftest_dictionaries.py)\n    - [Type Casting](src\u002Fdata_types\u002Ftest_type_casting.py)\n4. **Control Flow**\n    - [The `if` statement](src\u002Fcontrol_flow\u002Ftest_if.py)\n    - [The `for` statement](src\u002Fcontrol_flow\u002Ftest_for.py) (and `range()` function)\n    - [The `while` statement](src\u002Fcontrol_flow\u002Ftest_while.py)\n    - [The `try` statements](src\u002Fcontrol_flow\u002Ftest_try.py)\n    - [The `break` statement](src\u002Fcontrol_flow\u002Ftest_break.py)\n    - [The `continue` statement](src\u002Fcontrol_flow\u002Ftest_continue.py)\n5. **Functions**\n    - [Function Definition](src\u002Ffunctions\u002Ftest_function_definition.py) (`def` and `return` statements)\n    - [Scopes of Variables Inside Functions](src\u002Ffunctions\u002Ftest_function_scopes.py) (`global` and `nonlocal` statements)\n    - [Default Argument Values](src\u002Ffunctions\u002Ftest_function_default_arguments.py)\n    - [Keyword Arguments](src\u002Ffunctions\u002Ftest_function_keyword_arguments.py)\n    - [Arbitrary Argument Lists](src\u002Ffunctions\u002Ftest_function_arbitrary_arguments.py)\n    - [Unpacking Argument Lists](src\u002Ffunctions\u002Ftest_function_unpacking_arguments.py) (`*` and `**` statements)\n    - [Lambda Expressions](src\u002Ffunctions\u002Ftest_lambda_expressions.py) (`lambda` statement)\n    - [Documentation Strings](src\u002Ffunctions\u002Ftest_function_documentation_string.py)\n    - [Function Annotations](src\u002Ffunctions\u002Ftest_function_annotations.py)\n    - [Function Decorators](src\u002Ffunctions\u002Ftest_function_decorators.py)\n6. **Classes**\n    - [Class Definition](src\u002Fclasses\u002Ftest_class_definition.py) (`class` statement)\n    - [Class Objects](src\u002Fclasses\u002Ftest_class_objects.py)\n    - [Instance Objects](src\u002Fclasses\u002Ftest_instance_objects.py)\n    - [Method Objects](src\u002Fclasses\u002Ftest_method_objects.py)\n    - [Class and Instance Variables](src\u002Fclasses\u002Ftest_class_and_instance_variables.py)\n    - [Inheritance](src\u002Fclasses\u002Ftest_inheritance.py)\n    - [Multiple Inheritance](src\u002Fclasses\u002Ftest_multiple_inheritance.py)\n7. **Modules**\n    - [Modules](src\u002Fmodules\u002Ftest_modules.py) (`import` statement)\n    - [Packages](src\u002Fmodules\u002Ftest_packages.py)\n8. **Errors and Exceptions**\n    - [Handling Exceptions](src\u002Fexceptions\u002Ftest_handle_exceptions.py) (`try` statement)\n    - [Raising Exceptions](src\u002Fexceptions\u002Ftest_raise_exceptions.py) (`raise` statement)\n9. **Files**\n    - [Reading and Writing](src\u002Ffiles\u002Ftest_file_reading.py) (`with` statement)\n    - [Methods of File Objects](src\u002Ffiles\u002Ftest_file_methods.py)\n10. **Additions**\n    - [The `pass` statement](src\u002Fadditions\u002Ftest_pass.py)\n    - [Generators](src\u002Fadditions\u002Ftest_generators.py) (`yield` statement)\n11. **Brief Tour of the Standard Libraries**\n    - [Serialization](src\u002Fstandard_libraries\u002Ftest_json.py) (`json` library)\n    - [File Wildcards](src\u002Fstandard_libraries\u002Ftest_glob.py) (`glob` library)\n    - [String Pattern Matching](src\u002Fstandard_libraries\u002Ftest_re.py) (`re` library)\n    - [Mathematics](src\u002Fstandard_libraries\u002Ftest_math.py) (`math`, `random`, `statistics` libraries)\n    - [Dates and Times](src\u002Fstandard_libraries\u002Ftest_datetime.py) (`datetime` library)\n    - [Data Compression](src\u002Fstandard_libraries\u002Ftest_zlib.py) (`zlib` library)\n12. **User input**\n    - [Terminal input](src\u002Fuser_input\u002Ftest_input.py) (`input` statement)\n\n## Prerequisites\n\n**Installing Python**\n\nMake sure that you have [Python3 installed](https:\u002F\u002Frealpython.com\u002Finstalling-python\u002F) on your machine.\n\nYou might want to use [venv](https:\u002F\u002Fdocs.python.org\u002F3\u002Flibrary\u002Fvenv.html) standard Python library\nto create virtual environments and have Python, pip and all dependent packages to be installed and \nserved from the local project directory to avoid messing with system wide packages and their \nversions.\n\nDepending on your installation you might have access to Python3 interpreter either by\nrunning `python` or `python3`. The same goes for pip package manager - it may be accessible either\nby running `pip` or `pip3`.\n\nYou may check your Python version by running:\n\n```bash\npython --version\n```\n\nNote that in this repository whenever you see `python` it will be assumed that it is Python **3**.\n\n**Installing dependencies**\n\nInstall all dependencies that are required for the project by running:\n\n```bash\npip install -r requirements.txt\n```\n\n## Testing the Code\n\nTests are made using [pytest](https:\u002F\u002Fdocs.pytest.org\u002Fen\u002Flatest\u002F) framework.\n\nYou may add new tests for yourself by adding files and functions with `test_` prefix\n(i.e. `test_topic.py` with `def test_sub_topic()` function inside).\n\nTo run all the tests please execute the following command from the project root folder:\n\n```bash\npytest\n```\n\nTo run specific tests please execute:\n\n```bash\npytest .\u002Fpath\u002Fto\u002Fthe\u002Ftest_file.py\n```\n\n## Linting the Code\n\nLinting is done using [pylint](http:\u002F\u002Fpylint.pycqa.org\u002F) and [flake8](http:\u002F\u002Fflake8.pycqa.org\u002Fen\u002Flatest\u002F) libraries.\n\n### PyLint\n\nTo check if the code is written with respect\nto [PEP 8](https:\u002F\u002Fwww.python.org\u002Fdev\u002Fpeps\u002Fpep-0008\u002F) style guide please run:\n\n```bash\npylint .\u002Fsrc\u002F\n```\n\nIn case if linter will detect error (i.e. `missing-docstring`) you may want to read more about \nspecific error by running:\n\n```bash\npylint --help-msg=missing-docstring\n```\n\n[More about PyLint](http:\u002F\u002Fpylint.pycqa.org\u002F)\n\n### Flake8\n\nTo check if the code is written with respect\nto [PEP 8](https:\u002F\u002Fwww.python.org\u002Fdev\u002Fpeps\u002Fpep-0008\u002F) style guide please run:\n\n```bash\nflake8 .\u002Fsrc\n```\n\nOr if you want to have more detailed output you may run:\n\n```bash\nflake8 .\u002Fsrc --statistics --show-source --count\n```\n\n[More about Flake8](http:\u002F\u002Fflake8.pycqa.org\u002Fen\u002Flatest\u002F)\n\n## Author\n\n- [@trekhleb](https:\u002F\u002Ftrekhleb.dev)\n","该项目是一个用于学习Python的实践场和速查表，包含按主题分类的Python脚本及代码示例，并附有详细解释。其核心功能包括通过修改或添加代码来测试并理解其工作原理，同时提供代码检查以确保符合Python编码规范，从而帮助用户保持较高的代码质量。此外，每个脚本都包含了大量断言，使得即使不运行代码也能快速查看预期输出结果。非常适合初学者作为入门教程使用，也适合有一定基础的学习者复习巩固Python语法知识。",2,"2026-06-11 02:50:30","top_language"]