1.8. About Language
1.8.1. Summary
Turing complete, general purpose language
Multi platform
Dynamic typing with automatic memory allocation and GC
Code readability and simplicity is important
White space are important
Everything is an object, but you can write functional code too
Standard language in Machine Learning and Data Science
Very good standard system library
Huge ecosystem of external open source libraries
Open Source created by non-profit Python Software Foundation
1.8.2. Scripts
Python files use
.py
as an extensionCompiled files are in
__pycache__
directoryPython also uses other extensions
1.8.3. Python Console (REPL)
Read–Eval–Print Loop
Quickly test and evaluate code
Lines starts with
>>>
Line continuation starts with
...
Result is printed below
Open REPL with
python3
command in terminal
$ python
Python 3.13.0 (main, Oct 7 2024, 05:02:14) [Clang 16.0.0 (clang-1600.0.26.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> print('Hello World!')
Hello World!
In documentation and books you may find >>>
and ...
at the beginning of code listing lines
if True:
print('yes')
else:
print('no')
yes
1.8.4. Jupyter
Open Source web application REPL
Very popular in Machine Learning and Data Science world
Create and share documents that contain live code, equations, visualizations and narrative text
Uses include: data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, etc
1.8.5. References
1.8.6. Assignments
# %% About
# - Name: About Language Environment
# - Difficulty: easy
# - Lines: 0
# - Minutes: 3
# %% 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. Create file `about_env.py`
# 2. Run file in your IDE
# 3. Where Python is installed?
# 4. Are you using "venv"?
# 5. Make sure, `venv` is not `None`
# 6. Run doctests - all must succeed
# %% Polish
# 1. Stwórz plik `about_env.py`
# 2. Uruchom plik w swoim IDE
# 3. Gdzie Python jest zainstalowany?
# 4. Czy korzystasz z "venv"?
# 5. Upewnij się, że `venv` nie jest `None`
# 6. Uruchom doctesty - wszystkie muszą się powieść
# %% Tests
"""
>>> import sys; sys.tracebacklimit = 0
>>> assert sys.version_info >= (3, 9), \
'Python 3.9+ required'
>>> assert python_executable
>>> assert python_version
"""
# %% Run
# - PyCharm: right-click in the editor and `Run Doctest in ...`
# - PyCharm: keyboard shortcut `Control + Shift + F10`
# - Terminal: `python -m doctest -v myfile.py`
# %% Imports
import os
import sys
# %% Types
python_executable: str
python_version: tuple
venv: str
# %% Data
python_executable = sys.executable
python_version = tuple(sys.version_info)
venv = os.getenv("VIRTUAL_ENV")
# %% Result