נבנה על ידיBuilt by Ariel Yohimovich

PythonPython
1
חלקPart 1: יסודותFoundations כ-3 שעות (כולל הפסקה)About 3 hours (with a break)

מה זה תכנות? התקנה וטרמינלWhat is programming? Setup & terminal

איך מחשב מבצע הוראות, התקנת Python ו-VS Code ב-Windows וב-Mac, הטרמינל, והתוכנית הראשונה עם print.

How a computer follows instructions, installing Python and VS Code on Windows and Mac, the terminal, and a first program with print.

התקנה ב-Windows, צעד אחר צעדWindows installation, step by step

  1. נכנסים ל-python.org/downloads ולוחצים על הכפתור הצהוב Download Python.Go to python.org/downloads and click the yellow Download Python button.
  2. מריצים את הקובץ. לפני הכול מסמנים למטה Add python.exe to PATH.Run the file. Before anything else tick Add python.exe to PATH at the bottom.
  3. Install Now. אם מופיע "Disable path length limit", לוחצים עליו (לא מזיק, ועוזר בהמשך).Install Now. If "Disable path length limit" appears, click it (harmless and helps later).
  4. סוגרים ופותחים מחדש את PowerShell (חלון ישן לא מכיר את ההתקנה החדשה).Close and reopen PowerShell (an old window doesn't know about the new install).
  5. בודקים:Check:
PowerShell
python --version
py --version
פלט לדוגמהSample output
Python 3.13.18
Python 3.13.18
על הפקודה pyAbout the py command

py הוא "משגר" שמגיע עם Python ב-Windows. אם python לא עובד ו-py כן, אפשר להשתמש ב-py בכל מקום שכתוב python.

py is a launcher that ships with Python on Windows. If python fails but py works, use py wherever we write python.

התקנה ב-Mac, צעד אחר צעדMac installation, step by step

  1. מורידים מ-python.org/downloads את ה-macOS installer.Download the macOS installer from python.org/downloads.
  2. פותחים את קובץ ה-‎.pkg ועוברים על המסכים (Continue, Agree, Install).Open the .pkg file and go through the screens (Continue, Agree, Install).
  3. בתיקייה שנפתחת בסוף, לוחצים פעמיים על Install Certificates.command.In the folder that opens at the end, double-click Install Certificates.command.
  4. פותחים Terminal ובודקים:Open Terminal and check:
Terminal
python3 --version
פלט לדוגמהSample output
Python 3.13.18
שימו לבNote

אם מופיעה הודעה שמבקשת להתקין "command line developer tools", זה תקין: מאשרים, מחכים לסיום, ומריצים שוב. ב-Mac לא משתמשים ב-python לבד, רק ב-python3.

If a message asks to install "command line developer tools", that's fine: accept, wait for it to finish, and run again. On a Mac don't use plain python, only python3.

הגדרת VS CodeSetting up VS Code

  1. מתקינים מ-code.visualstudio.com.Install from code.visualstudio.com.
  2. Extensions (Ctrl+Shift+X) → מחפשים Python (של Microsoft) → Install.Extensions (Ctrl+Shift+X) → search Python (by Microsoft) → Install.
  3. File → Open Folder → בוחרים את python-course.File → Open Folder → choose python-course.
  4. בוחרים מפרש: Ctrl+Shift+P → Python: Select Interpreter → בוחרים את Python 3.12 ומעלה.Pick an interpreter: Ctrl+Shift+P → Python: Select Interpreter → choose Python 3.12+.
  5. מפעילים File → Auto Save.Turn on File → Auto Save.
  6. טרמינל בתוך VS Code: View → Terminal (או Ctrl+`).Terminal inside VS Code: View → Terminal (or Ctrl+`).
טיפTip

ב-Mac מחליפים את Ctrl ב-Cmd בקיצורים.

On a Mac, replace Ctrl with Cmd in shortcuts.

פקודות המפגשCommands for this session

פעולהActionMac (Terminal)Mac (Terminal)Windows (PowerShell)Windows (PowerShell)
גרסת PythonPython versionpython3 --versionpython --version
איפה אניWhere am Ipwdpwd
מה יש בתיקייהList the folderlsdir
כניסה לתיקייהEnter a foldercd namecd name
תיקייה אחת למעלהUp one foldercd ..cd ..
יצירת תיקייהMake a foldermkdir namemkdir name
הרצת קובץRun a filepython3 hello.pypython hello.py
מצב אינטראקטיביInteractive modepython3python
פתיחת התיקייה ב-VS CodeOpen folder in VS Codecode .code .
ניקוי מסךClear screenclearcls
טיפTip

החץ למעלה ↑ בטרמינל מחזיר את הפקודה הקודמת, ו-Tab משלים שמות של קבצים ותיקיות. חוסך המון הקלדה ושגיאות כתיב.

The up arrow ↑ brings back the previous command, and Tab completes file and folder names. Saves lots of typing and typos.

פתרון בעיות נפוצותTroubleshooting

בעיהProblemסיבהCauseפתרוןFix
'python' is not recognized (Windows)'python' is not recognized (Windows)Python לא ב-PATHPython isn't on PATHלהריץ שוב את ההתקנה → Modify → לסמן PATH. לפתוח PowerShell חדש. בינתיים: pyRerun the installer → Modify → tick PATH. Open a new PowerShell. Meanwhile: py
python3 פותח את Microsoft Store (Windows)python3 opens the Microsoft Store (Windows)קיצור דרך של WindowsA Windows shortcut aliasמשתמשים ב-python או py. אפשר לכבות ב-Settings → Manage App Execution AliasesUse python or py. You can turn it off in Settings → Manage App Execution Aliases
command not found: python (Mac)command not found: python (Mac)ב-Mac הפקודה היא python3On a Mac the command is python3מקלידים python3Type python3
can't open file ... No such filecan't open file ... No such fileלא בתיקייה הנכונה או שם שגויWrong folder or wrong namepwd ו-ls, ואז cd לתיקייה הנכונהpwd and ls, then cd into the right folder
▶ ב-VS Code מריץ גרסה ישנה של הקוד▶ in VS Code runs an old version of the codeהקובץ לא נשמרThe file wasn't savedCtrl+S או Auto SaveCtrl+S or Auto Save
אין כפתור ▶ ב-VS CodeNo ▶ button in VS Codeתוסף Python לא מותקן או הקובץ לא ‎.pyPython extension missing or the file isn't .pyלהתקין את התוסף ולוודא שהשם נגמר ב-‎.pyInstall the extension and make sure the name ends in .py
עברית מוצגת הפוך בטרמינלHebrew shows reversed in the terminalלחלק מהטרמינלים אין תמיכה מלאה בכיוון ימין-לשמאלSome terminals lack full right-to-left supportזה רק בתצוגה. הטקסט עצמו תקין. אפשר להשתמש בטרמינל של VS CodeIt's display only; the text itself is fine. You can use VS Code's terminal

נבנה על ידיBuilt by Ariel Yohimovich