CodeDala
Home
Courses
Paths
Marketplace
How it works
Pricing
🌐
KZ
RU
EN
Log in
Start free
Order a project
Py+
💻 For developers
Python: Next Level
Functions, files, errors, OOP, and final projects — the sequel to «Python From Scratch»
What you'll build
📘
A solid foundation
⚡
Practice in the browser
🎯
Mini-projects
🎓
Course certificate
📘 58
lessons
⏱ 1-2 evenings
🎓 Advanced
🎯 Mission
Master Python: Next Level
⚡
+630
XP
🏆
Certificate
PDF
🎓
Course complete
Progress
0 / 58 · 0%
Next up:
What a function is and why you need it
Start the project →
Course program
01
Функции
0 / 12 lessons
⌄
01
What a function is and why you need it
def — declare a function
•
name() — call it
•
Code reuse
⚡ +10
▶ Now
02
Parameters — passing data inside
def f(name):
•
Parameter and argument
•
Access inside the function
⚡ +10
Open
03
Multiple parameters
def f(a, b)
•
Order matters
•
Comma between parameters
⚡ +10
Open
04
return — returning a result
return a value
•
Can store in a variable
•
Without return, a function returns None
⚡ +10
🔒 Pro
05
Default parameters
def f(x=10)
•
Can call without an argument
•
Required first, then defaults
⚡ +10
🔒 Pro
06
Keyword arguments
f(name=...)
•
Order doesn’t matter
•
Handy for long parameter lists
⚡ +10
🔒 Pro
07
Local and global variables
Inside a function — local
•
Outside — global
•
Local isn’t visible outside
⚡ +10
🔒 Pro
08
*args — a variable number of arguments
def f(*args)
•
args is a tuple
•
Pass as many as you want
⚡ +10
🔒 Pro
09
**kwargs — keyword arguments in a bundle
def f(**kwargs)
•
kwargs is a dictionary
•
Flexible settings
⚡ +10
🔒 Pro
10
Lambdas — a function in one line
lambda x: ...
•
An anonymous function
•
When you need it for one action
⚡ +10
🔒 Pro
11
Recursion — a function calls itself
Base case
•
Step deeper
•
Without a base — infinity
⚡ +10
🔒 Pro
12
Mini-project: a function library for a calculator
4 functions with return
•
Used in sequence
•
Default parameters
⚡ +10
🔒 Pro
02
Файлы и ввод-вывод
0 / 10 lessons
⌄
13
Files — what they are and why
open(name, mode)
•
Writing in "w"
•
Closing the file
⚡ +10
🔒 Pro
14
with — safe opening and auto-closing
with open(...) as f:
•
Body — indented 4 spaces
•
Closing is guaranteed
⚡ +10
🔒 Pro
15
Reading the whole file — read()
Mode "r"
•
f.read() → one big string
•
Printing the contents
⚡ +10
🔒 Pro
16
Reading line by line — for line in file
for line in f:
•
Each line separately
•
rstrip() removes \n
⚡ +10
🔒 Pro
17
Writing "w" — overwriting a file
Mode "w" erases the old
•
writelines for a list
•
Add the newline yourself
⚡ +10
🔒 Pro
18
Appending "a" — adding to the end
Mode "a" doesn’t erase
•
Adds to the end
•
Handy for logs
⚡ +10
🔒 Pro
19
encoding="utf-8" — Cyrillic and emoji without trouble
By default — the system encoding
•
encoding="utf-8" is universal
•
Without it you get «mojibake»
⚡ +10
🔒 Pro
20
JSON — dictionary ↔ string
json.dumps(data)
•
json.loads(text)
•
Handy for data exchange
⚡ +10
🔒 Pro
21
JSON to a file — dump and load
json.dump(data, f) — no s
•
json.load(f) — no s
•
A file object, not a string
⚡ +10
🔒 Pro
22
Mini-project: saving notes to JSON
A list of dictionaries
•
json.dump to a file
•
json.load back
⚡ +10
🔒 Pro
03
Ошибки и исключения
0 / 8 lessons
⌄
23
What an exception is
A runtime error
•
The program crashes with a traceback
•
Built-in error types
⚡ +10
🔒 Pro
24
try / except — catching an error
try: the risky code
•
except: what to do on an error
•
The program does NOT crash
⚡ +10
🔒 Pro
25
Several types in one except
except (A, B):
•
Several options
•
A tuple of types in parentheses
⚡ +10
🔒 Pro
26
else — run ONLY if there was no error
try: we attempt
•
except: we catch
•
else: everything went well
⚡ +10
🔒 Pro
27
finally — always runs
Runs after try/except/else
•
Even when returning from a function
•
Useful for cleaning up resources
⚡ +10
🔒 Pro
28
raise — throwing your own error
raise ValueError("...")
•
When the input data is bad
•
Signalling «can’t go further»
⚡ +10
🔒 Pro
29
Your own exception class
class MyError(Exception):
•
A clear name for a business error
•
raise + except as usual
⚡ +10
🔒 Pro
30
Mini-project: a safe calculator
A function with try/except
•
raise for business rules
•
Clear messages
⚡ +10
🔒 Pro
04
ООП
0 / 14 lessons
⌄
31
What a class and an object are
class — a template
•
An object — a concrete instance
•
Creation via name()
⚡ +10
🔒 Pro
32
__init__ and self — the object constructor
__init__ runs automatically
•
self is the object itself
•
self.attr = ... stores in the object
⚡ +10
🔒 Pro
33
Multiple attributes
Several self.x = ...
•
Each object — with its own set
•
Commas between __init__ parameters
⚡ +10
🔒 Pro
34
Methods — functions inside a class
def method(self)
•
Call via object.method()
•
You can use self.x inside
⚡ +10
🔒 Pro
35
__str__ — a nice object representation
By default — a technical form
•
def __str__(self) → string
•
print() and f-strings call it
⚡ +10
🔒 Pro
36
A list of objects — working with a collection
Objects can go into a list
•
for loop over the list
•
Access each one’s attribute
⚡ +10
🔒 Pro
37
A method that changes the object’s state
self.attr = ... in a method
•
The object «remembers» changes
•
Several methods on one object
⚡ +10
🔒 Pro
38
Class attributes — shared across all instances
Declared DIRECTLY inside class
•
Without self
•
Accessed via ClassName.attr or self.attr
⚡ +10
🔒 Pro
39
Private attributes — the _underscore convention
_name — «don’t touch from outside»
•
Not real protection, a convention
•
Access via a method
⚡ +10
🔒 Pro
40
Inheritance — class Cat(Animal)
A child class gets the parent’s methods
•
class Child(Parent):
•
Free — whatever the parent has
⚡ +10
🔒 Pro
41
super() — extending the parent constructor
super().__init__(...)
•
First the parent __init__
•
Then your own self.x = ...
⚡ +10
🔒 Pro
42
Overriding methods
A child class can overwrite a parent method
•
Same name — different behavior
•
Polymorphism
⚡ +10
🔒 Pro
43
Composition — an object inside an object
An attribute can be an object
•
Access via a chain of dots
•
An alternative to inheritance
⚡ +10
🔒 Pro
44
Mini-project: a bank account
A class with methods and state
•
raise on an error
•
__str__ for nice output
⚡ +10
🔒 Pro
05
Модули и стандартная библиотека
0 / 8 lessons
⌄
45
What a module is and why you need it
import math and others
•
Access via math.pi / math.sqrt
•
The standard library
⚡ +10
🔒 Pro
46
from ... import ... — taking only what you need
from module import name
•
No prefix in code
•
Several names via commas
⚡ +10
🔒 Pro
47
as — giving a module a short name
import name as short
•
Useful for long names
•
Conventions like np / pd
⚡ +10
🔒 Pro
48
random — random numbers
randint(a, b) — an integer in a range
•
choice(list) — a random element
•
Each run gives something different
⚡ +10
🔒 Pro
49
datetime — date and time
from datetime import datetime
•
datetime.now() — the current moment
•
Attributes .year .month .day
⚡ +10
🔒 Pro
50
math — advanced functions
math.factorial(n)
•
math.floor / math.ceil
•
math.gcd for GCD
⚡ +10
🔒 Pro
51
collections.Counter — a counter out of the box
from collections import Counter
•
Counter(data) — frequencies
•
.most_common(N) — top N
⚡ +10
🔒 Pro
52
Mini-project: a password generator
random.choices with k
•
Joining via .join
•
Length — a function parameter
⚡ +10
🔒 Pro
06
Финальные мини-проекты
0 / 6 lessons
⌄
53
Project: a TODO list with priorities
A list of dictionaries
•
add_task / show_tasks functions
•
Sorting by priority
⚡ +10
🔒 Pro
54
Project: a currency converter
Rates as a dictionary
•
convert function via USD
•
round rounding
⚡ +10
🔒 Pro
55
Project: a notes diary in JSON
A class with add / save / load methods
•
JSON for saving
•
A loop over entries
⚡ +10
🔒 Pro
56
Project: «Guess the number»
random + while
•
A list of guesses
•
Hints higher / lower
⚡ +10
🔒 Pro
57
Project: tracking books in a library
Two classes: Book and Library
•
__str__ for Book
•
Search by the author field
⚡ +10
🔒 Pro
58
Финал: ToDo-менеджер с сохранением
Класс TodoApp
•
JSON для постоянства
•
Все приёмы вместе
🎓
Course complete
🔒 Pro
Python: Next Level — online coding course