პროგრამირების საწყისები (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
კონტექსტი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
ნაბიჯი 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 PATHSkip 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.
print "გამარჯობა" ფრჩხილების გარეშე — ეს ძველი კოდია.
Python 2 will not help youIt was retired in 2020. If you ever see print "hello" without parentheses, that is old code.
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+R → cmd) და აკრიფე:
Open a terminal (Windows: Win+R → cmd) 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
ნაბიჯი 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()
ნაბიჯი 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 |
|---|---|---|
| Python | ms-python.python |
მთავარი. ინტერპრეტატორის არჩევა, გაშვება, ტესტები. თან მოაქვს დანარჩენი ორი. The main one. Interpreter selection, running, testing. Pulls in the other two. |
| Pylance | ms-python.vscode-pylance |
ავტოშევსება, ტიპების შემოწმება, შეცდომების ჩვენება წერისასვე. Autocomplete, type checking, errors flagged as you type. |
| Python Debugger | ms-python.debugpy |
Breakpoint-ები, ნაბიჯ-ნაბიჯ შესრულება, ცვლადების დათვალიერება. Breakpoints, step-by-step execution, inspecting variables. |
ნაბიჯი 3 · სასურველიStep 3 · Recommended
დანამატები, რომლებიც ცხოვრებას გიმსუბუქებსExtensions that make life easier
| დანამატიExtension | ID | რატომWhy |
|---|---|---|
| Ruff | charliermarsh.ruff |
ავტოფორმატირება + სტილის შემოწმება (PEP 8). ძალიან სწრაფი. → XIV კვირა Auto-formatting + style checks (PEP 8). Very fast. → Week XIV |
| Error Lens | usernamehw.errorlens |
შეცდომას პირდაპირ ხაზზე გიწერს, არა ქვედა პანელში. დამწყებისთვის — ოქრო. Shows the error on the line itself, not in a bottom panel. Gold for beginners. |
| Python Indent | KevinRose.vsc-python-indent |
სწორად „ხვდება“ სად უნდა გაწიოს კოდი. Python-ში ეს კრიტიკულია. Guesses the right indentation. In Python that matters a lot. |
| indent-rainbow | oderwat.indent-rainbow |
წანაცვლების დონეებს აფერადებს — ციკლების/პირობების შეცდომები თვალით ჩანს. Colours indentation levels — loop and branch mistakes become visible. |
| Code Runner | formulahendry.code-runner |
ერთი ღილაკით გაშვება (Ctrl+Alt+N). Run with one shortcut (Ctrl+Alt+N). |
| Jupyter | ms-toolsai.jupyter |
ინტერაქტიული უჯრები — მაგალითების ცოცხლად ჩვენებისთვის. Interactive cells — handy for live demos. |
| GitLens | eamodio.gitlens |
ვერსიების კონტროლი VS Code-შივე. → XV კვირა Version control inside VS Code. → Week XV |
სწრაფი გზა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+P → Preferences: Open User Settings (JSON) Ctrl+Shift+P → Preferences: 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" }
}
}
ნაბიჯი 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.
- Ctrl+Shift+P
- აკრიფე
Python: Select Interpreter - აირჩიე ვერსია სიიდან (მაგ.
Python 3.13.1 64-bit)
- Ctrl+Shift+P
- Type
Python: Select Interpreter - 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.
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
ინსტრუმენტიTool
ჩაშენებული ტერმინალიThe built-in terminal
Ctrl+` — ხსნის და ხურავს ტერმინალს რედაქტორის შიგნით.
Ctrl+` — opens and closes a terminal inside the editor.
- რატომ სჭირდება?პროგრამის გაშვება, პაკეტების დაყენება, ვერსიების შემოწმება — ყველაფერი ერთ ფანჯარაში
- Windows-ზე ორი ვარიანტიაPowerShell (ნაგულისხმევი) და Command Prompt. ორივე გამოდგება — ბრძანებები, რომლებსაც ვიყენებთ, იდენტურია
- Why bother?Running programs, installing packages, checking versions — all in one window
- Two options on WindowsPowerShell (default) and Command Prompt. Either works — the commands we use are identical
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
დეტალურად — 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.
- დააწკაპე ხაზის ნომრის მარცხნივ → გამოჩნდება წითელი წერტილი (breakpoint)
- დააჭირე F5 → პროგრამა გაჩერდება იმ ხაზზე
- მარცხენა პანელში ხედავ ყველა ცვლადის მიმდინარე მნიშვნელობას
- F10 ერთი ნაბიჯი · F11 ფუნქციაში შესვლა · F5 გაგრძელება
- Click to the left of a line number → a red dot appears (breakpoint)
- Press F5 → the program pauses on that line
- The left panel shows the current value of every variable
- F10 step over · F11 step into · F5 continue
დიაგნოსტიკა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?
python --versionაბრუნებს 3.10+ ვერსიას- VS Code დაყენებულია და იხსნება
- დანამატი Python (ms-python.python) დაყენებულია
- Python: Select Interpreter-ით ვერსია არჩეულია
- საქაღალდე გახსნილია File ▸ Open Folder-ით (არა ცალკე ფაილი!)
hello.pyიქმნება, ეშვება და ტექსტს გამოიტანს- ჩაშენებული ტერმინალი იხსნება Ctrl+`-ით
python --versionreports 3.10 or newer- VS Code is installed and opens
- The Python extension (ms-python.python) is installed
- An interpreter is chosen via Python: Select Interpreter
- A folder is open via File ▸ Open Folder (not a single file!)
hello.pycan be created, run, and prints its text- The built-in terminal opens with Ctrl+`