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

חזרה למפגשBack
PythonPython

מה זה תכנות?What is programming?

מפגש 1: התקנה, טרמינל והתוכנית הראשונהSession 1: setup, terminal and the first program

מה נעשה היוםToday's plan

  • מה זה תכנות ולמה PythonWhat programming is and why Python
  • מתקינים Python ו-VS CodeInstall Python and VS Code
  • מכירים את הטרמינלMeet the terminal
  • כותבים ומריצים תוכנית ראשונהWrite and run a first program
  • קוראים שגיאה בלי פאניקהRead an error without panic

המטרה של הקורסThe goal of the course

מהשורה הראשונה ועד פרויקטים אמיתיים וראיון עבודה ראשוןFrom your first line to real projects and a first job interview
נושאTopic 1

מה זה תכנות?What is programming?

מחשב לא מנחשA computer never guesses

  • עושה בדיוק מה שאומרים לוDoes exactly what it is told
  • תוכנית = רשימת הוראות לפי הסדרProgram = a list of instructions, in order
  • תכנות = לכתוב את ההוראות בשפה שהמחשב מביןProgramming = writing those instructions in a language it understands

רובוט-שףThe robot chef

מתכון = תוכנית. הרובוט מבצע כל צעד בדיוק. כתבתם "ביצם" במקום "ביצים"? הוא עוצר ואומר "לא הבנתי".Recipe = program. The robot does each step exactly. Wrote "egs" instead of "eggs"? It stops and says "I didn't understand".

התוכנית הראשונהThe first program

hello.py
print("שלום! התוכנית הראשונה שלי")
print("Python רצה שורה אחרי שורה")
print("Hello! My first program")
print("Python runs line by line")
פלטOutput
שלום! התוכנית הראשונה שלי
Python רצה שורה אחרי שורה
Hello! My first program
Python runs line by line

P גדולה = מילה אחרתCapital P = a different word

hello.py
Print("שלום")
Print("Hello")
מה Python עונהWhat Python says
NameError: name 'Print' is not defined. Did you mean: 'print'?
Python רגישה לאותיות גדולות וקטנות. מתקנים ל-print.Python is case-sensitive. Fix it to print.
נושאTopic 2

למה Python?Why Python?

Python בכל מקוםPython everywhere

  • אוטומציה של משימותAutomating tasks
  • נתונים וגרפיםData and charts
  • אתרים ו-APIWebsites and APIs
  • AI ומודלי שפהAI and language models
  • משחקים (חלק 7!)Games (part 7!)

המפרש = מתורגמןThe interpreter = a translator

המפרש שומע שורה, מתרגם אותה למחשב, והמחשב מבצע. ואז השורה הבאה.The interpreter hears a line, translates it for the computer, the computer acts. Then the next line.

מירכאות משנות הכולQuotes change everything

quotes.py
print(2 + 3)
print("2 + 3")
פלטOutput
5
2 + 3

חישוב חצי גמורA half-written calculation

quotes.py
print(2 +)
מה Python עונהWhat Python says
SyntaxError: invalid syntax
SyntaxError = השורה לא לפי חוקי השפה. משלימים את החישוב.SyntaxError = the line breaks the language rules. Finish the calculation.
נושאTopic 3

התקנת PythonInstalling Python

WindowsWindows

  • מורידים מ-python.orgDownload from python.org
  • מסמנים Add python.exe to PATHTick Add python.exe to PATH
  • Install NowInstall Now
  • ב-PowerShell: python --versionIn PowerShell: python --version

MacMac

  • מורידים מ-python.org ומתקינים את ה-‎.pkgDownload from python.org and install the .pkg
  • לוחצים פעמיים על Install Certificates.commandDouble-click Install Certificates.command
  • ב-Terminal: python3 --versionIn Terminal: python3 --version
  • ב-Mac תמיד python3On a Mac it's always python3

בודקים שהכול עובדCheck that it works

Terminal
python3 --version
פלט לדוגמהSample output
Python 3.13.18

"python is not recognized""python is not recognized"

ב-Windows: לא סימנו PATH. מריצים שוב את ההתקנה → Modify, או מנסים py --version.On Windows: PATH wasn't ticked. Run the installer again → Modify, or try py --version.

הפסקהBreak

10 דקות. מי שההתקנה לא עבדה לו, בואו אליי.10 minutes. If your install didn't work, come see me.
נושאTopic 4

הטרמינלThe terminal

מה זה טרמינל?What is a terminal?

  • חלון שמקלידים בו פקודותA window where you type commands
  • Mac: Terminal · Windows: PowerShellMac: Terminal · Windows: PowerShell
  • תמיד עומד בתיקייה נוכחית אחתAlways stands in one current directory

5 פקודות שמספיקות5 commands are enough

MacMac
  • pwd
  • ls
  • cd folder
  • cd ..
  • mkdir name
WindowsWindows
  • pwd
  • dir
  • cd folder
  • cd ..
  • mkdir name

לנווט בבנייןMoving through a building

pwd = באיזה חדר אני · ls = מה בחדר · cd = להיכנס לדלת · cd .. = לצאת למסדרוןpwd = which room am I in · ls = what's in it · cd = go through a door · cd .. = back to the hallway

יוצרים את תיקיית הקורסCreate the course folder

Terminal
cd Desktop
mkdir python-course
cd python-course
pwd
שאלה לכיתהQuestion for the class

אתם ב-Desktop. איך נכנסים ל-python-course ואז חוזרים?You're in Desktop. How do you enter python-course and come back?

  • cd python-course ואז cd ..cd python-course then cd ..
  • open python-course ואז backopen python-course then back
  • go python-course ואז exitgo python-course then exit

No such file or directoryNo such file or directory

Python מחפשת את הקובץ רק בתיקייה הנוכחית. בודקים pwd ו-ls, ואת האיות של השם.Python only looks in the current folder. Check pwd, ls and the spelling of the name.
נושאTopic 5

VS CodeVS Code

מכינים את VS CodeSetting up VS Code

  • מתקינים מ-code.visualstudio.comInstall from code.visualstudio.com
  • תוסף Python של MicrosoftThe Python extension by Microsoft
  • File → Open Folder → python-courseFile → Open Folder → python-course
  • קובץ חדש: hello.pyNew file: hello.py

hello.pyhello.py

hello.py
print("שלום מ-VS Code!")
print("הקובץ הזה הוא סקריפט")
print("כל הכבוד לי!")
print("Hello from VS Code!")
print("This file is a script")
print("Well done, me!")
פלטOutput
שלום מ-VS Code!
הקובץ הזה הוא סקריפט
כל הכבוד לי!
Hello from VS Code!
This file is a script
Well done, me!

שמירה אוטומטיתAuto Save

File → Auto Save. Python מריצה את מה ששמור בדיסק, לא את מה שעל המסך.File → Auto Save. Python runs what's saved on disk, not what's on screen.
נושאTopic 6

printprint

print היא פונקציהprint is a function

  • פעולה עם שם, מפעילים עם סוגרייםA named action, run with parentheses
  • טקסט במירכאות = מחרוזתText in quotes = a string
  • כמה ערכים? מפרידים בפסיקSeveral values? Separate with commas
  • print() ריקה = שורה ריקהAn empty print() = a blank line

כמה דברים ביחדSeveral things at once

print_demo.py
print("2 + 3 =", 2 + 3)
print("להתראות", "👋")
print("2 + 3 =", 2 + 3)
print("Bye", "👋")
פלטOutput
2 + 3 = 5
להתראות 👋
2 + 3 = 5
Bye 👋

מירכאות שלא נסגרוUnclosed quotes

hello.py
print("שלום)
print("Hello)
מה Python עונהWhat Python says
SyntaxError: unterminated string literal (detected at line 1)
תמיד שתי מירכאות: בהתחלה ובסוף.Always two quotes: at the start and at the end.
נושאTopic 7

Python כמחשבוןPython as a calculator

האופרטוריםThe operators

calc.py
print(7 + 3, 7 - 3, 7 * 3)
print(7 / 2)
print(7 // 2, 7 % 2)
print(2 ** 10)
פלטOutput
10 4 21
3.5
3 1
1024

7 עוגיות, 2 ילדים7 cookies, 2 kids

כל ילד מקבל 7 // 2 = 3, ונשארת 7 % 2 = 1.Each kid gets 7 // 2 = 3, and 7 % 2 = 1 is left.

סדר פעולותOrder of operations

calc.py
print(2 + 3 * 4)
print((2 + 3) * 4)
פלטOutput
14
20

חילוק באפסDivision by zero

calc.py
print(10 / 0)
מה Python עונהWhat Python says
ZeroDivisionError: division by zero
אי אפשר לחלק באפס. Python עוצרת את התוכנית.You can't divide by zero. Python stops the program.
נושאTopic 8

הערות והזחהComments and indentation

הערות עם #Comments with #

card.py
# כרטיס ביקור
print("דנה כהן")
# print("לא יודפס")
print("dana@example.com")
# A business card
print("Dana Cohen")
# print("won't print")
print("dana@example.com")
פלטOutput
דנה כהן
dana@example.com
Dana Cohen
dana@example.com

רווח בתחילת שורהA space at the start

card.py
print("ראשונה")
 print("שנייה")
print("First")
 print("Second")
מה Python עונהWhat Python says
IndentationError: unexpected indent
ב-Python להזחה יש משמעות. מוחקים את הרווח.In Python indentation has meaning. Delete the space.
נושאTopic 9

REPL מול סקריפטREPL vs script

שתי דרכים להריץTwo ways to run

REPL ‏>>>REPL >>>
  • ניסוי מהירQuick experiment
  • לא נשמרNot saved
  • python3python3
סקריפט ‎.pyScript .py
  • תוכנית לשמורA program to keep
  • נשמר בקובץSaved in a file
  • python3 hello.pypython3 hello.py

>>> בתוך קובץ>>> inside a file

hello.py
>>> print("Hi")
מה Python עונהWhat Python says
SyntaxError: invalid syntax
>>> זה רק התצוגה של ה-REPL. מוחקים.>>> is just the REPL display. Delete it.
נושאTopic 10

קוראים שגיאותReading errors

Traceback: קוראים מלמטהTraceback: read from the bottom

  • שורה אחרונה: מה קרהLast line: what happened
  • מעליה: איפה (קובץ ושורה)Above it: where (file and line)
  • השורות לפני השגיאה כן רצוLines before the error did run

3 שאלות לכל שגיאה3 questions for every error

מה הסוג? · איפה? · מה שונה ממה שהתכוונתי?What type? · Where? · What differs from what I meant?
נושאTopic 11

הפרויקט המלווהThe companion project

מדף: הספרייה האישיתShelf: your personal library

  • היום: 10 שורות עם printToday: 10 lines with print
  • בהמשך: קלט, רשימות, קבציםLater: input, lists, files
  • בסוף: API, מסד נתונים, בדיקות ו-CLIIn the end: an API, a database, tests and a CLI

מה למדנוWhat we learned

  • תוכנית = הוראות לפי הסדרProgram = instructions in order
  • התקנו Python ו-VS CodeInstalled Python and VS Code
  • pwd, ls/dir, cd, mkdirpwd, ls/dir, cd, mkdir
  • print, אופרטורים והערותprint, operators and comments
  • שגיאות = עזרהErrors = help

עכשיו לתרגול!Now, practice!

3 שאלות חימום, 8 תרגילים ו-2 אתגרים3 warm-ups, 8 exercises and 2 challenges
הערות מרצהSpeaker notes

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