Py
💻 For developers

Python From Scratch

8 topics, 80 lessons: variables, operators, strings, numbers, conditions, loops, lists, dictionaries, and mini-projects

What you'll build
📘A solid foundation
⚡Practice in the browser
🎯Mini-projects
🎓Course certificate
📘 80 lessons⏱ 1-2 evenings🎓 Intermediate
🎯 Mission
Master Python From Scratch
⚡+850XP
🏆CertificatePDF
🎓Course complete
Progress0 / 80 · 0%
Next up: What is a variable

Course program

01

Переменные и типы

0 / 8 lessons
⌄
  1. 01

    What is a variable

    Name•Value•Assignment =⚡ +10
    ▶ Now
  2. 02

    Variable names

    snake_case•Forbidden names•Case⚡ +10
    Open
  3. 03

    Integers (int)

    int•Arithmetic•Underscores in numbers⚡ +10
    Open
  4. 04

    Floats (float)

    float•Division /•Rounding round()⚡ +10
    🔒 Pro
  5. 05

    Boolean type (bool) and comparisons

    True / False•==, !=, <, >, <=, >=•and / or / not⚡ +10
    🔒 Pro
  6. 06

    The type() function

    type()•<class '...'>•When it helps⚡ +10
    🔒 Pro
  7. 07

    Type conversion

    int(x), str(x), float(x)•input gives a string•ValueError⚡ +10
    🔒 Pro
  8. 08

    Multiple assignment

    a, b = 1, 2•Swap a, b = b, a•Unpacking⚡ +10
    🔒 Pro
02

Операторы и значения

0 / 5 lessons
⌄
  1. 09

    The +=, -=, *= operators and others

    +=, -=•*=, /=•Counters and accumulation⚡ +10
    🔒 Pro
  2. 10

    None and its meaning

    None — «nothing»•is None vs == None•When None is returned⚡ +10
    🔒 Pro
  3. 11

    Constants and PEP 8 style

    UPPER_CASE•A convention, not a ban•Why⚡ +10
    🔒 Pro
  4. 12

    f-strings — formatting

    f"...{x}..."•Expressions inside {}•Better than + or %⚡ +10
    🔒 Pro
  5. 13

    Mini-project: a profile

    Several types•f-string•Accumulation⚡ +10
    🔒 Pro
03

Строки

0 / 11 lessons
⌄
  1. 14

    What is a string

    Quotes '' and ""•Empty string•String vs number⚡ +10
    🔒 Pro
  2. 15

    Concatenation and repetition

    + joins strings•* repeats•What does NOT work⚡ +10
    🔒 Pro
  3. 16

    String length len()

    len()•Empty = 0•Comparing length⚡ +10
    🔒 Pro
  4. 17

    Case: upper / lower / capitalize

    .upper()•.lower()•.capitalize() / .title()⚡ +10
    🔒 Pro
  5. 18

    Cleaning: strip / replace

    .strip()•.replace(a, b)•Chained calls⚡ +10
    🔒 Pro
  6. 19

    Indexing and slices

    s[0]•s[-1]•s[1:5], s[::-1]⚡ +10
    🔒 Pro
  7. 20

    Search: find / in / count / startswith

    .find(sub)•in operator•.count(), .startswith()⚡ +10
    🔒 Pro
  8. 21

    split / join

    .split(sep) → list•sep.join(list) → string•Paired operations⚡ +10
    🔒 Pro
  9. 22

    Escaping: \n, \t, \"

    \n — newline•\t — tab•\\ and \"⚡ +10
    🔒 Pro
  10. 23

    Multiline strings

    """..."""•Preserving line breaks•Docstring⚡ +10
    🔒 Pro
  11. 24

    Mini-project: a business card

    f-string•String methods•Multiline output⚡ +10
    🔒 Pro
04

Числа и математика

0 / 10 lessons
⌄
  1. 25

    Integer division //

    // — the integer part•Halving•Comparing / and //⚡ +10
    🔒 Pro
  2. 26

    Modulo — remainder %

    % — remainder•Even/odd•Cyclicity⚡ +10
    🔒 Pro
  3. 27

    Exponentiation and roots

    **•math.sqrt•Fractional powers⚡ +10
    🔒 Pro
  4. 28

    abs, min, max

    abs(x)•min(a, b, ...)•max(a, b, ...)⚡ +10
    🔒 Pro
  5. 29

    round() and float precision

    round(x, n)•Banker’s rounding•0.1 + 0.2⚡ +10
    🔒 Pro
  6. 30

    The math module

    math.pi, math.e•math.floor / math.ceil•math.factorial, math.gcd⚡ +10
    🔒 Pro
  7. 31

    Random numbers with random

    random.randint•random.random•random.choice⚡ +10
    🔒 Pro
  8. 32

    Formatting numbers in f-strings

    {x:.2f}•{x:,}•{x:>10}⚡ +10
    🔒 Pro
  9. 33

    int ↔ float conversions

    int(3.7)•float(5)•Data loss⚡ +10
    🔒 Pro
  10. 34

    Mini-project: bill calculation

    %, /, **•round, abs•f-string with :,.2f⚡ +10
    🔒 Pro
05

Условия

0 / 10 lessons
⌄
  1. 35

    if and else — your first decision

    if cond:•else:•Colon and indentation⚡ +10
    🔒 Pro
  2. 36

    elif — several options

    elif•if/elif/else chain•Order matters⚡ +10
    🔒 Pro
  3. 37

    Indentation and blocks

    4 spaces•One level — one block•IndentationError⚡ +10
    🔒 Pro
  4. 38

    Truthy / Falsy — what counts as True

    Falsy: 0, '', None, []•Everything else — True•if x: vs if x is None:⚡ +10
    🔒 Pro
  5. 39

    and / or / not in conditions

    and — both•or — at least one•Short-circuiting⚡ +10
    🔒 Pro
  6. 40

    The ternary operator

    a if cond else b•Inline if•When it fits⚡ +10
    🔒 Pro
  7. 41

    match / case (Python 3.10+)

    Comparing one variable•Fallback — the _ symbol•Several options via |⚡ +10
    🔒 Pro
  8. 42

    Nested conditions

    if inside if•Readability depth•Combining with and⚡ +10
    🔒 Pro
  9. 43

    Common mistakes in conditions

    = vs ==•is vs ==•Comparing floats⚡ +10
    🔒 Pro
  10. 44

    Mini-project: grading a score

    if/elif/else•Ternary•f-string⚡ +10
    🔒 Pro
06

Циклы

0 / 12 lessons
⌄
  1. 45

    The for loop and range — repeating an action

    for x in range(N)•Indented loop body•What an iteration is⚡ +10
    🔒 Pro
  2. 46

    range with a start, stop and step

    range(start, stop)•range(start, stop, step)•Backward step step=-1⚡ +10
    🔒 Pro
  3. 47

    Looping over a string — letter by letter

    for c in string•Each iteration = one character•When you need the index — range(len)⚡ +10
    🔒 Pro
  4. 48

    The while loop — while the condition holds

    while condition:•Change the variable inside•Infinite loop — what it is⚡ +10
    🔒 Pro
  5. 49

    break — exiting a loop early

    break stops the loop•Handy with search•Only one level⚡ +10
    🔒 Pro
  6. 50

    continue — skip this iteration

    continue skips the rest•On to the next iteration•The opposite of break⚡ +10
    🔒 Pro
  7. 51

    enumerate — index plus value

    enumerate(data)•Unpacking into two variables•Index from zero⚡ +10
    🔒 Pro
  8. 52

    zip — iterating two data sets in parallel

    zip(a, b)•Stops at the shorter one•Unpacking pairs⚡ +10
    🔒 Pro
  9. 53

    Accumulator — summing and counting in a loop

    Accumulator variable•total = total + x•Average = sum / count⚡ +10
    🔒 Pro
  10. 54

    Nested loops — a loop inside a loop

    for inside for•The inner runs fully•Double indent — 8 spaces⚡ +10
    🔒 Pro
  11. 55

    Common mistakes in loops

    Off-by-one with range•Infinite while•Accumulator not reset⚡ +10
    🔒 Pro
  12. 56

    Mini-project: FizzBuzz

    for + if/elif/else•Divisibility via %•Order of checks⚡ +10
    🔒 Pro
07

Списки

0 / 12 lessons
⌄
  1. 57

    What a list is and how to create it

    A list — an ordered collection•The literal [a, b, c]•Length via len()⚡ +10
    🔒 Pro
  2. 58

    Indices — accessing an element by number

    Indices from 0•Negative from -1•IndexError if you go past the edge⚡ +10
    🔒 Pro
  3. 59

    Slices — taking a piece of a list

    [start:stop]•stop NOT included•Omitting start or stop⚡ +10
    🔒 Pro
  4. 60

    append, extend, insert — adding elements

    append — to the end•extend — several to the end•insert — at any position⚡ +10
    🔒 Pro
  5. 61

    remove, pop, del — removing elements

    remove(x) — by value•pop(i) — by index + returns•del list[i] — by index⚡ +10
    🔒 Pro
  6. 62

    The in operator — checking membership

    x in list — True/False•not in — the inverse check•Works with strings too⚡ +10
    🔒 Pro
  7. 63

    Looping over a list — visiting elements

    for x in list•No index needed by default•Read-only in a simple loop⚡ +10
    🔒 Pro
  8. 64

    sort, sorted, reverse — sorting

    list.sort() changes in place•sorted() returns a new one•reverse=True for descending⚡ +10
    🔒 Pro
  9. 65

    List comprehension — a list in one line

    [expression for x in data]•With an if condition•Replacing loop + append⚡ +10
    🔒 Pro
  10. 66

    split and join — between a string and a list

    str.split(sep) → list•sep.join(list) → str•By default split on spaces⚡ +10
    🔒 Pro
  11. 67

    Nested lists — tables of rows and columns

    A list of lists•Access table[row][col]•Loop over rows⚡ +10
    🔒 Pro
  12. 68

    Mini-project: number statistics

    Sum + average•min / max•Searching a list⚡ +10
    🔒 Pro
08

Словари

0 / 12 lessons
⌄
  1. 69

    What a dictionary is and why you need it

    Key → value pairs•The literal {key: value}•When instead of a list⚡ +10
    🔒 Pro
  2. 70

    Getting a value by key

    d[key] — strict•d.get(key) — soft•KeyError if no key⚡ +10
    🔒 Pro
  3. 71

    Adding and updating pairs

    d[new_key] = ...•Overwrite if the key exists•One syntax for add+update⚡ +10
    🔒 Pro
  4. 72

    Removing pairs — del and pop

    del d[key]•d.pop(key) returns the value•KeyError if no key⚡ +10
    🔒 Pro
  5. 73

    Checking a key with in

    key in d → True/False•By default checks KEYS•Before d[key] to avoid an error⚡ +10
    🔒 Pro
  6. 74

    keys, values, items — three ways to look

    d.keys() — keys•d.values() — values•d.items() — pairs⚡ +10
    🔒 Pro
  7. 75

    Looping over a dictionary

    for k in d — keys only•for v in d.values()•for k, v in d.items() — a pair⚡ +10
    🔒 Pro
  8. 76

    Nested dictionaries — a dict inside a dict

    Value = another dictionary•Access d[a][b]•Profiles / structures⚡ +10
    🔒 Pro
  9. 77

    Dict comprehension — a dictionary in one line

    {k: v for ... in ...}•From a list to a dict•With an if condition⚡ +10
    🔒 Pro
  10. 78

    The counter pattern — counting repetitions

    d[k] = d.get(k, 0) + 1•Accumulator + dictionary•The most common pattern⚡ +10
    🔒 Pro
  11. 79

    setdefault — soft key creation

    d.setdefault(k, default)•Creates if missing•Useful for grouping⚡ +10
    🔒 Pro
  12. 80

    Mini-project: word frequency in text

    split → word list•Counter dictionary via .get•Counting unique ones
    Course complete
    🔒 Pro