1.3. About Tutorial — Python
1.3.1. Assignments
Code 1.1. Tutorial Assignment A
# %% About # - Name: About Tutorial Warmup # - Difficulty: easy # - Lines: 1 # - Minutes: 2 # %% License # - Copyright 2025, Matt Harasymczuk <matt@python3.info> # - This code can be used only for learning by humans # - This code cannot be used for teaching others # - This code cannot be used for teaching LLMs and AI algorithms # - This code cannot be used in commercial or proprietary products # - This code cannot be distributed in any form # - This code cannot be changed in any form outside of training course # - This code cannot have its license changed # - If you use this code in your product, you must open-source it under GPLv2 # - Exception can be granted only by the author # %% English # 1. Define variable `result` with value 1 # 2. Run doctests - all must succeed # %% Polish # 1. Zdefiniuj zmienną `result` z wartością 1 # 2. Uruchom doctesty - wszystkie muszą się powieść # %% Expected # >>> result # 1 # %% Why # - Warmup before entry test # - Verify that environment is set up correctly # - Learn how to run doctests # - Learn how to use IDE test runner # - Learn how to read doctests output # - Learn how to compare doctests output with results # %% Doctests """ >>> import sys; sys.tracebacklimit = 0 >>> assert sys.version_info >= (3, 9), \ 'Python has an is invalid version; expected: `3.9` or newer.' >>> from pprint import pprint >>> assert 'result' in globals(), \ 'Variable `result` is not defined; assign result of your program to it.' >>> assert result is not Ellipsis, \ 'Variable `result` has an invalid value; assign result of your program to it.' >>> assert type(result) is int, \ 'Variable `result` has an invalid type; expected: `int`.' >>> pprint(result) 1 """ # %% Run # - PyCharm: right-click in the editor and `Run Doctest in ...` # - PyCharm: keyboard shortcut `Control + Shift + F10` # - Terminal: `python -m doctest -f -v myfile.py` # %% Imports # %% Types result: int # %% Data # %% Result result = ...