jetbrains_logo

ML Intensive for TLF

Lecture 1. Python Refresher


Alex Avdiushenko
August 17, 2026

Main Goals of the Intensive

  • To understand deeply basic concepts of machine learning and neural networks
  • To implement AI models using Python and PyTorch
  • To be useful for the international IOAI Olympiad (https://ioai-official.org/)
  • To take the first step, after which you can continue self-study


Homework every day is optional, and also we will share some additional materials 👍

Instructors

Aleksandr Avdiushenko

Alex Avdiushenko

Lecturer, Researcher and Data Scientist with 10+ years of experience in data science, analysis, and educational programs for the tech industry. I worked as a researcher at the academy, an analyst at Yandex and a lecturer at leading universities in Russia and the world. Now I am a lecturer and researcher at JetBrains.

Mike Romanov

Mike Romanov

PhD in Scientific Computing with research contributions in computer vision and generative modeling (CVPR, IROS, h-index 8, 260 citations). Senior Deep Learning Engineer with production experience in diffusion models and large-scale generative systems. Sixteen years of university-level teaching in mathematics and machine learning.

Python Language IS

  • easy to start using
  • free and open source
  • (almost) portable
  • high-level
  • interpreted, not compiled
  • well suited for REPL = Read Eval Print Loop
python_after_cpp

First example of Python code

python_interpretation

Another Example

Writing in Python is like writing pseudocode. Suppose you know, that

\[ e^x=\sum_{k=0}^\infty \frac{1}{k!}x^k = 1 + x + \frac{x^2}{2!} + \dots \]
value_of_e

A few tasks to solve (10-15 min)

  1. Middle of Three
  2. Fizz Buzz
  3. Flatten It (generator)

Everything in Python is an object

Every object has:

  • id — where it's located (~memory address)
  • type — a set of values and operations on these values
  • value — the actual value

Size of INT in Python language

What do you think, how much memory INT takes?

  • In general, 1 bit represents only two values (it's 0 or 1)
  • 1 byte = 8 bits, and this already represents integers from 0 to 255 or from -127 to 127

Can it be depending on the platform:

  • 4 bytes (32 bits) or
  • 8 bytes (64 bits)?

Why so much and not the same?

Cpython open source realization:


									struct _longobject {
										// macros with
										// 1. the object’s reference counter (8 bytes)
										// 2. and a pointer to the corresponding type object (8 bytes)
										// 3. and extension field ob_size (8 bytes)
										PyObject_VAR_HEAD
										// int value adds 0, 4 (32x) or 8 bytes (64x)
										// SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
										digit ob_digit[1];
									};
								

DEMO: tools for programming and studying Python

  1. Install PyCharm IDE
  2. Quick start guide, need to specify a Python interpreter
  3. Download JetBrains Academy plugin
  4. All the assignments and deadlines can be found on the ML Intesive for TML
  5. Homework 1: If you are not familiar with Python, then go through py section 26 tasks here in browser or in PyCharm ❤️