პროგრამირების საწყისები (Python) Programming Essentials (Python)

სამუშაო გარემოს
მომზადება
Setting up your
environment

Python-ის ინტერპრეტატორი · VS Code · აუცილებელი დანამატები The Python interpreter · VS Code · the extensions you actually need

I კვირა — პრაქტიკული საათი Week I — lab session

ეს სლაიდები დაურიგე სტუდენტებს — ბევრი მათგანი სახლის კომპიუტერზე მარტო დააყენებს. სთხოვე ბოლო სლაიდის checklist გაიაროს. Hand these out — many students will install everything alone at home. Ask them to walk through the checklist on the last slide.

კონტექსტიContext

რა გვჭირდება რეალურად?What do we actually need?

1 · ინტერპრეტატორი1 · The interpreter

პროგრამა, რომელიც კითხულობს და ასრულებს შენს კოდს. ესაა Python თავად.

The program that reads and runs your code. This is Python itself.

  • მის გარეშე კოდი უბრალო ტექსტია
  • Without it, code is just text

2 · რედაქტორი2 · The editor

პროგრამა, რომელშიც კოდს წერ. ესაა VS Code.

The program you write code in. This is VS Code.

  • ჩანაცვლებადია: PyCharm, Vim, Notepad++
  • Interchangeable: PyCharm, Vim, Notepad++

3 · ტერმინალი3 · The terminal

ადგილი, სადაც პროგრამას უშვებ და პასუხს ხედავ.

Where you run the program and see its output.

  • VS Code-ს საკუთარი აქვს ჩაშენებული
  • VS Code has one built in
მთავარი აზრიეს სამი ცალკე რამაა. თუ რომელიმე გატყდა, დანარჩენს არაფერი უშავს — და ეს დიაგნოსტიკას ამარტივებს. The key ideaThese are three separate things. If one breaks, the others are unaffected — which makes diagnosing problems much easier.

ნაბიჯი 1Step 1

Python-ის დაყენებაInstalling Python

Windows

  • ჩამოტვირთე python.org/downloads
  • ინსტალაციისას აუცილებლად:
    ☑ Add python.exe to PATH თუ ეს არ მონიშნე — ტერმინალი ვერ იპოვის Python-ს
  • „Install Now“ საკმარისია
  • Download from python.org/downloads
  • During installation, do not miss:
    ☑ Add python.exe to PATH Skip this and the terminal will not find Python
  • “Install Now” is enough

macOS / LinuxmacOS / Linux

  • macOS: brew install python
  • Fedora: sudo dnf install python3
  • Ubuntu: sudo apt install python3 python3-pip
  • macOS: brew install python
  • Fedora: sudo dnf install python3
  • Ubuntu: sudo apt install python3 python3-pip

რომელი ვერსია?Which version?

ნებისმიერი Python 3.10+. კურსში 3.12/3.13 ვგულისხმობთ.

Any Python 3.10+. This course assumes 3.12 / 3.13.

Python 2 არ გამოგადგებაის 2020 წელს გაუქმდა. თუ სადმე ნახავ print "გამარჯობა" ფრჩხილების გარეშე — ეს ძველი კოდია. Python 2 will not help youIt was retired in 2020. If you ever see print "hello" without parentheses, that is old code.
Microsoft Store-ის PythonWindows-ზე python-ის აკრეფამ შეიძლება Store გახსნას. ეს ნიშნავს, რომ ნამდვილი Python არაა დაყენებული ან PATH-ში არაა. The Microsoft Store stubOn Windows, typing python may open the Store. That means the real Python is either not installed or not on PATH.

ნაბიჯი 1 · შემოწმებაStep 1 · Verify

დარწმუნდი, რომ იმუშავაMake sure it worked

გახსენი ტერმინალი (Windows: Win+Rcmd) და აკრიფე:

Open a terminal (Windows: Win+Rcmd) and type:

python --version
Python 3.13.1

pip --version
pip 24.3.1 from ...

Windows-ზე ალტერნატივა: py -V · Linux/macOS: python3 --version On Windows also: py -V · Linux/macOS: python3 --version

„python is not recognized“ / „command not found“PATH არაა მოწესრიგებული. მარტივი გამოსავალი: ხელახლა გაუშვი ინსტალატორი → Modify → მონიშნე Add to PATH. შემდეგ დახურე და ხელახლა გახსენი ტერმინალი. “python is not recognized” / “command not found”PATH is not set up. The simple fix: run the installer again → Modify → tick Add to PATH. Then close and reopen the terminal.

ნაბიჯი 1 · ბონუსიStep 1 · Bonus

REPL — ინტერაქტიული რეჟიმიThe REPL — interactive mode

უბრალოდ აკრიფე python ტერმინალში — მიიღებ „ცოცხალ“ Python-ს:

Just type python in the terminal and you get a live Python:

>>> 2 + 3 * 4
14
>>> "გამარჯობა" + " " + "მსოფლიო"
'გამარჯობა მსოფლიო'
>>> exit()
რისთვის?სწრაფი ექსპერიმენტისთვის: „როგორ იქცევა ეს ფუნქცია?“ — ფაილის შექმნა არ გჭირდება. კურსის განმავლობაში ხშირად გამოვიყენებთ. What for?Quick experiments: “how does this function behave?” — no need to create a file. We will use it constantly.
აქ ცოცხლად აჩვენე: მოკლე გამოთვლა, სტრიქონის შეერთება, შემდეგ განზრახ შეცდომა (მაგ. 1/0) — რომ ნახონ traceback-ის სახე. Demo it live: a quick calculation, string concatenation, then a deliberate error (e.g. 1/0) so they see what a traceback looks like.

ნაბიჯი 2Step 2

რატომ VS Code?Why VS Code?

უფასო და ღიაFree and open

კოდი MIT ლიცენზიით. სრულიად ღია ალტერნატივა — VSCodium (ტელემეტრიის გარეშე).

MIT-licensed source. A fully open alternative is VSCodium (no telemetry).

ერთი და იგივე ყველგანThe same everywhere

Windows · macOS · Linux — იდენტური ინტერფეისი. ლექციაზე და სახლში ერთნაირად გამოიყურება.

Windows · macOS · Linux — identical interface. It looks the same in class and at home.

მსუბუქიLightweight

ჩართავ და მუშაობს. ძლიერდება მხოლოდ იმ დანამატებით, რომლებიც შენ დაამატე.

Install and it works. It only grows with the extensions you add yourself.

ინდუსტრიის სტანდარტიAn industry standard

ყველაზე გავრცელებული რედაქტორი დეველოპერებში — ეს უნარი სამსახურშიც გამოგადგება.

The most widely used editor among developers — this skill transfers to a job.

ჩამოტვირთვა: code.visualstudio.com · ალტერნატივები: PyCharm Community, Thonny (დამწყებთათვის), Vim/Neovim Download: code.visualstudio.com · Alternatives: PyCharm Community, Thonny (for beginners), Vim/Neovim

ნაბიჯი 3 · სავალდებულოStep 3 · Essential

დანამატები, რომელთა გარეშეც არ ღირსExtensions you should not skip

დანამატიExtension ID რას აკეთებსWhat it does
Pythonms-python.python მთავარი. ინტერპრეტატორის არჩევა, გაშვება, ტესტები. თან მოაქვს დანარჩენი ორი. The main one. Interpreter selection, running, testing. Pulls in the other two.
Pylancems-python.vscode-pylance ავტოშევსება, ტიპების შემოწმება, შეცდომების ჩვენება წერისასვე. Autocomplete, type checking, errors flagged as you type.
Python Debuggerms-python.debugpy Breakpoint-ები, ნაბიჯ-ნაბიჯ შესრულება, ცვლადების დათვალიერება. Breakpoints, step-by-step execution, inspecting variables.
რეალურად ერთი დაყენება„Python“ დანამატის დაყენებისას Pylance და Debugger ავტომატურად მოჰყვება. ესაა მინიმუმი, რომლითაც კურსი მთლიანად გაივლის. Really just one installInstalling “Python” brings Pylance and the Debugger along automatically. That is the minimum needed for the whole course.

ნაბიჯი 3 · სასურველიStep 3 · Recommended

დანამატები, რომლებიც ცხოვრებას გიმსუბუქებსExtensions that make life easier

დანამატიExtension ID რატომWhy
Ruffcharliermarsh.ruff ავტოფორმატირება + სტილის შემოწმება (PEP 8). ძალიან სწრაფი. → XIV კვირა Auto-formatting + style checks (PEP 8). Very fast. → Week XIV
Error Lensusernamehw.errorlens შეცდომას პირდაპირ ხაზზე გიწერს, არა ქვედა პანელში. დამწყებისთვის — ოქრო. Shows the error on the line itself, not in a bottom panel. Gold for beginners.
Python IndentKevinRose.vsc-python-indent სწორად „ხვდება“ სად უნდა გაწიოს კოდი. Python-ში ეს კრიტიკულია. Guesses the right indentation. In Python that matters a lot.
indent-rainbowoderwat.indent-rainbow წანაცვლების დონეებს აფერადებს — ციკლების/პირობების შეცდომები თვალით ჩანს. Colours indentation levels — loop and branch mistakes become visible.
Code Runnerformulahendry.code-runner ერთი ღილაკით გაშვება (Ctrl+Alt+N). Run with one shortcut (Ctrl+Alt+N).
Jupyterms-toolsai.jupyter ინტერაქტიული უჯრები — მაგალითების ცოცხლად ჩვენებისთვის. Interactive cells — handy for live demos.
GitLenseamodio.gitlens ვერსიების კონტროლი VS Code-შივე. → XV კვირა Version control inside VS Code. → Week XV
არ დაატვირთო პირველივე დღეს ყველა დანამატით. სავალდებულო სამი + Error Lens — სრულიად საკმარისია I–V კვირისთვის. Do not overload them on day one. The three essentials plus Error Lens are plenty for weeks I–V.

სწრაფი გზაThe fast way

ყველაფერი ერთი ბრძანებითEverything in one command

თუ code ბრძანება ხელმისაწვდომია ტერმინალში:

If the code command is available in your terminal:

code --install-extension ms-python.python
code --install-extension charliermarsh.ruff
code --install-extension usernamehw.errorlens
code --install-extension KevinRose.vsc-python-indent
code --install-extension oderwat.indent-rainbow

ხელით: Ctrl+Shift+X → ჩაწერე სახელი → Install By hand: Ctrl+Shift+X → type the name → Install

ჯგუფური მუშაობისთვისფაილი .vscode/extensions.json პროექტში ჩააგდე — VS Code თავად შესთავაზებს გუნდის წევრებს დაყენებას. For teamworkDrop a .vscode/extensions.json into the project — VS Code will offer the same set to everyone.

ნაბიჯი 4Step 4

პარამეტრები, რომლებსაც ერთხელ ვაწყობთSettings you configure once

Ctrl+Shift+PPreferences: Open User Settings (JSON) Ctrl+Shift+PPreferences: Open User Settings (JSON)

{
  "editor.fontSize": 15,
  "editor.tabSize": 4,
  "editor.insertSpaces": true,
  "editor.rulers": [79],
  "editor.formatOnSave": true,
  "files.autoSave": "afterDelay",
  "files.trimTrailingWhitespace": true,

  "[python]": {
    "editor.defaultFormatter": "charliermarsh.ruff",
    "editor.codeActionsOnSave": { "source.organizeImports": "explicit" }
  }
}
tabSize 4 + spacesPEP 8-ის მოთხოვნაა. ტაბებისა და ჰარეების შერევა Python-ში შეცდომაა, არა სტილის საკითხი. tabSize 4 + spacesRequired by PEP 8. Mixing tabs and spaces in Python is an error, not a style choice.
rulers [79]ვერტიკალური ხაზი გახსენებს, სად უნდა გადაიტანო სტრიქონი. rulers [79]A vertical guide reminding you where to wrap a line.

ნაბიჯი 5Step 5

სწორი ინტერპრეტატორის არჩევაSelecting the right interpreter

ეს ყველაზე ხშირი დაბნეულობის წყაროა. VS Code უნდა იცოდეს, რომელი Python გაუშვას.

This is the most common source of confusion. VS Code needs to know which Python to run.

  1. Ctrl+Shift+P
  2. აკრიფე Python: Select Interpreter
  3. აირჩიე ვერსია სიიდან (მაგ. Python 3.13.1 64-bit)
  1. Ctrl+Shift+P
  2. Type Python: Select Interpreter
  3. Pick a version from the list (e.g. Python 3.13.1 64-bit)

არჩეული ვერსია ჩანს ქვედა ზოლში (status bar), მარჯვნივ. The selected version appears in the status bar, bottom right.

ტიპური სიმპტომი„ბიბლიოთეკა დავაყენე pip-ით, მაგრამ VS Code ამბობს ModuleNotFoundError“ → სავარაუდოდ pip სხვა Python-ში დააყენა, ვიდრე VS Code იყენებს. Typical symptom“I installed the library with pip, but VS Code says ModuleNotFoundError” → pip most likely installed it into a different Python than the one VS Code uses.

პირველი პროგრამაFirst program

hello.py

შექმენი საქაღალდე (მაგ. python-course) → VS Code → File ▸ Open Folder → ახალი ფაილი hello.py Create a folder (e.g. python-course) → VS Code → File ▸ Open Folder → new file hello.py

print("გამარჯობა, მსოფლიო!")
print("Python-ის კურსი დაიწყო")

გაშვების სამი გზაThree ways to run it

ზედა მარჯვენა კუთხეში, „Run Python File“Top-right corner, “Run Python File”

ტერმინალიდანFrom the terminal

python hello.py

Ctrl+F5

გამართვის გარეშე გაშვებაRun without debugging

სთხოვე ყველას ეკრანზე გამოიტანოს საკუთარი სახელი — უმცირესი წარმატება პირველ 10 წუთში მოტივაციისთვის ძალიან მნიშვნელოვანია. Have everyone print their own name — a small win in the first ten minutes matters a lot for motivation.

ინსტრუმენტიTool

ჩაშენებული ტერმინალიThe built-in terminal

Ctrl+` — ხსნის და ხურავს ტერმინალს რედაქტორის შიგნით.

Ctrl+` — opens and closes a terminal inside the editor.

python hello.py          # პროგრამის გაშვება / run the program
pip install requests     # პაკეტის დაყენება / install a package
pip list                 # რა მაქვს დაყენებული / what is installed
cd folder                # საქაღალდეში გადასვლა / change directory
cls / clear              # ეკრანის გასუფთავება / clear the screen

კარგი ჩვევაGood habit

ვირტუალური გარემო (venv)Virtual environments (venv)

ცალკე „ყუთი“ თითოეული პროექტისთვის, სადაც მისი ბიბლიოთეკები ცხოვრობს.

A separate box for each project, holding just that project’s libraries.

# შექმნა / create (in the project folder)
python -m venv .venv

# გააქტიურება / activate — Windows
.venv\Scripts\activate

# გააქტიურება / activate — macOS / Linux
source .venv/bin/activate

# ახლა pip მხოლოდ ამ პროექტში დააყენებს
# now pip installs only into this project
pip install requests
რატომ?პროექტს A სჭირდება ბიბლიოთეკის 1.0 ვერსია, პროექტს B — 2.0. ერთ საერთო Python-ში ეს კონფლიქტია. venv ამ პრობლემას საერთოდ აცილებს. Why?Project A needs version 1.0 of a library, project B needs 2.0. In one shared Python that is a conflict. A venv avoids the problem entirely.

დეტალურად — XIV–XV კვირაზე (პაკეტები და pypi). ახლა უბრალოდ იცოდე, რომ არსებობს. In detail in weeks XIV–XV (packages and PyPI). For now, just know it exists.

ინსტრუმენტიTool

გამართვა (debugging) — F5Debugging — F5

„print-ებით ძებნა“ მუშაობს, მაგრამ დებაგერი უფრო სწრაფია.

Hunting with print statements works, but the debugger is faster.

  1. დააწკაპე ხაზის ნომრის მარცხნივ → გამოჩნდება წითელი წერტილი (breakpoint)
  2. დააჭირე F5 → პროგრამა გაჩერდება იმ ხაზზე
  3. მარცხენა პანელში ხედავ ყველა ცვლადის მიმდინარე მნიშვნელობას
  4. F10 ერთი ნაბიჯი · F11 ფუნქციაში შესვლა · F5 გაგრძელება
  1. Click to the left of a line number → a red dot appears (breakpoint)
  2. Press F5 → the program pauses on that line
  3. The left panel shows the current value of every variable
  4. F10 step over · F11 step into · F5 continue
როდის გამოვიყენოთროცა შედეგი არასწორია, მაგრამ არ ვიცი რომელ ნაბიჯზე გაფუჭდა. → XII კვირა (შეცდომები) When to reach for itWhen the result is wrong but you do not know which step broke it. → Week XII (errors)

დიაგნოსტიკაTroubleshooting

ხშირი პრობლემებიCommon problems

სიმპტომიSymptom მიზეზი და გამოსავალიCause and fix
'python' is not recognized PATH-ში არაა. ინსტალატორი → Modify → ☑ Add to PATH → ტერმინალის გადატვირთვა Not on PATH. Installer → Modify → ☑ Add to PATH → restart the terminal
Microsoft Store იხსნებაMicrosoft Store opens ნამდვილი Python არაა დაყენებული. დააყენე python.org-იდან The real Python is not installed. Install it from python.org
ModuleNotFoundError არასწორი ინტერპრეტატორია არჩეული → Python: Select Interpreter The wrong interpreter is selected → Python: Select Interpreter
IndentationError ტაბები და ჰარეები აირია → "editor.insertSpaces": true Tabs and spaces are mixed → "editor.insertSpaces": true
ქართული ტექსტი „კუბიკებია“Text shows as boxes ფაილი UTF-8-ში არაა შენახული ან ტერმინალის შრიფტი არ უჭერს მხარს The file is not saved as UTF-8, or the terminal font lacks the glyphs
ავტოშევსება არ მუშაობსAutocomplete does not work Pylance გამორთულია ან ინტერპრეტატორი არაა არჩეული Pylance is disabled, or no interpreter is selected

შემაჯამებელიWrap-up

Checklist — გავიარეთ თუ არა?Checklist — are we set up?

შემდეგილექცია 01 — Python-ის ისტორია, სინტაქსი, პროგრამის სტრუქტურა და კომენტარები. NextLecture 01 — Python’s history, syntax, program structure and comments.
ვისაც არ გამოუვიდა — სთხოვე ჯგუფის ჩატში დაწეროს ზუსტი შეცდომის ტექსტი. სახლში დარჩენილი პრობლემა მეორე კვირაზე უკვე ჩამორჩენაა. Anyone stuck should post the exact error text in the group chat. A problem left unsolved at home becomes a week-two gap.