נבנה על ידי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.

כותבים את הקוד ב-VS Code במחשב שלכם ומריצים. בכל תרגיל אפשר לפתוח רמזים בהדרגה, לראות איך הפלט אמור להיראות, ולסמן "פתרתי". בהמשך הקורס (אחרי מפגש 6) תוכלו להריץ ולבדוק כל תרגיל ישירות בדפדפן.Write the code in VS Code on your computer and run it. Each exercise has hints you open one at a time, a peek at the expected output, and an "I solved it" button. Later in the course (after session 6) you'll be able to run and check every exercise right in the browser.

חימום: 3 שאלותWarm-up: 3 questions

1. מה ידפיס הקוד הזה?What does this code print?
python
print("2 + 3")

2. איזו פקודה בודקת את גרסת Python ב-Mac?Which command checks the Python version on a Mac?

3. מה יקרה כשנריץ את הקוד?What happens when we run this code?
python
Print("Hi")

תרגיליםExercises

תרגילExercise 1

בונים את תיקיית הקורסSet up the course folder

נבדק ידניתSelf-checked

במחשב שלכם, בטרמינל אמיתי: צרו על שולחן העבודה תיקייה בשם python-course, היכנסו אליה, צרו בה קובץ hello.py (דרך VS Code) עם השורה print("Hi"), והריצו אותו מהטרמינל.

On your own computer, in a real terminal: create a folder named python-course on the Desktop, go into it, create hello.py in it (with VS Code) containing print("Hi"), and run it from the terminal.

רמזHint 1: ב-Mac פותחים Terminal, וב-Windows פותחים PowerShell. מתחילים ב-cd Desktop.On a Mac open Terminal; on Windows open PowerShell. Start with cd Desktop.
רמזHint 2: mkdir python-course ואחר כך cd python-course.mkdir python-course then cd python-course.
רמזHint 3: ב-VS Code: File → Open Folder, בוחרים את התיקייה, ואז New File בשם hello.py. בסוף בטרמינל: python3 hello.py.In VS Code: File → Open Folder, pick the folder, then New File named hello.py. Finally in the terminal: python3 hello.py.
לפתרוןSolution
תרגילExercise 2

שלום, עולם (בגרסה שלכם)Hello, world (your version)

כתבו תוכנית שמדפיסה שתי שורות: ברכה עם השם שלכם, ומשפט על משהו שאתם אוהבים.

Write a program that prints two lines: a greeting with your name, and a sentence about something you love.

איך הפלט אמור להיראות?What should the output look like?
שלום, אני נועה!
אני אוהבת פיצה וטיולים
Hi, I am Noa!
I love pizza and hiking
main.py
רמזHint 1: כל שורת פלט היא print נפרדת.Each output line is a separate print.
רמזHint 2: טקסט תמיד בתוך מירכאות: print("...").Text always goes inside quotes: print("...").
לפתרוןSolution
תרגילExercise 3

כרטיס ביקורBusiness card

הדפיסו כרטיס ביקור של 5 שורות לפחות: קו עליון, שם, תפקיד (למשל "מתכנת/ת Python מתחיל/ה"), אימייל, וקו תחתון. הוסיפו הערה אחת עם # שמסבירה מה התוכנית עושה.

Print a business card of at least 5 lines: a top border, a name, a role (e.g. "Beginner Python developer"), an email, and a bottom border. Add one # comment explaining what the program does.

איך הפלט אמור להיראות?What should the output look like?
-------------------------
נועה לוי
מפתחת Python מתחילה
noa@example.com
-------------------------
-------------------------
Noa Levi
Beginner Python developer
noa@example.com
-------------------------
main.py
רמזHint 1: קו אפשר לצייר עם הרבה מקפים: print("-------------").Draw a border with lots of dashes: print("-------------").
רמזHint 2: הערה מתחילה ב-# ו-Python מתעלמת ממנה.A comment starts with # and Python ignores it.
רמזHint 3: רוצים שורה ריקה באמצע? print().Want a blank line in the middle? print().
לפתרוןSolution
תרגילExercise 4

ציור ASCIIASCII art

ציירו בפלט חתול, בית או רובוט, בעזרת תווים רגילים בלבד. לפחות 5 שורות.

Draw a cat, a house or a robot in the output, using plain characters only. At least 5 lines.

איך הפלט אמור להיראות?What should the output look like?
  /\_/\  
 ( o.o ) 
  > ^ <  
 /     \ 
(_______)
main.py
רמזHint 1: כל שורה של הציור היא print נפרדת.Each line of the drawing is a separate print.
רמזHint 2: רווחים בתוך המירכאות נשמרים, כך שאפשר להזיז חלקים ימינה.Spaces inside the quotes are kept, so you can shift parts across.
רמזHint 3: שימו לב: התו \ הוא תו מיוחד במחרוזת. אם צריך אותו, כתבו \\ (פעמיים).Careful: \ is special in strings. If you need it, write \\ (twice).
לפתרוןSolution
תרגילExercise 5

מחשבון זמניםTime calculator

הדפיסו, עם כיתוב ברור, כמה שעות יש בשבוע וכמה דקות יש ביממה. Python צריכה לחשב, לא אתם!

Print, with clear labels, how many hours are in a week and how many minutes are in a day. Let Python calculate, not you!

איך הפלט אמור להיראות?What should the output look like?
שעות בשבוע: 168
דקות ביממה: 1440
Hours in a week: 168
Minutes in a day: 1440
main.py
רמזHint 1: שעות בשבוע = 7 ימים × 24 שעות. כפל ב-Python: *.Hours in a week = 7 days × 24 hours. Multiply in Python: *.
רמזHint 2: כיתוב וחישוב באותה שורה: print("כיתוב:", 7 * 24).Label and calculation on one line: print("label:", 7 * 24).
לפתרוןSolution
תרגילExercise 6

צייד באגיםBug hunter

בקוד הזה יש 3 באגים. הריצו, קראו כל הודעת שגיאה, תקנו אחד-אחד עד שהתוכנית מדפיסה 3 שורות.

This code has 3 bugs. Run it, read each error, fix them one by one until the program prints 3 lines.

איך הפלט אמור להיראות?What should the output look like?
מתחילים!
2 * 21 = 42
סוף
Let's go!
2 * 21 = 42
The end
main.py
רמזHint 1: Python מראה שגיאה אחת בכל פעם. מתקנים, מריצים שוב, ורואים את הבאה.Python shows one error at a time. Fix, run again, see the next.
רמזHint 2: שגיאות תחביר (מירכאות, רווחים) Python מוצאת עוד לפני שהיא מתחילה להריץ.Syntax errors (quotes, spaces) are found before Python even starts running.
רמזHint 3: חפשו: אות גדולה, רווחים בהתחלה, ומירכאות חסרות.Look for: a capital letter, leading spaces, and a missing quote.
לפתרוןSolution
תרגילExercise 7

קבלה מהמכולתGrocery receipt

קניתם 2 כיכרות לחם ב-8 ₪, 3 חלב ב-6 ₪ וגבינה אחת ב-12.5 ₪. הדפיסו קבלה: שורה לכל מוצר עם המחיר הכולל שלו, ובסוף שורת סה״כ. כל החישובים ב-Python.

You bought 2 loaves of bread at 8, 3 milks at 6 and one cheese at 12.5. Print a receipt: a line per product with its total price, and a final total line. All maths in Python.

איך הפלט אמור להיראות?What should the output look like?
לחם: 16
חלב: 18
גבינה: 12.5
----------
סה״כ: 46.5
Bread: 16
Milk: 18
Cheese: 12.5
----------
Total: 46.5
main.py
רמזHint 1: מחיר מוצר: כמות × מחיר, למשל 2 * 8.Product price: quantity × price, e.g. 2 * 8.
רמזHint 2: סה״כ: מחברים את שלושת החישובים בשורה אחת.Total: add the three calculations in one line.
רמזHint 3: מספר עשרוני כותבים עם נקודה: 12.5.Write decimals with a dot: 12.5.
לפתרוןSolution
תרגילExercise 8

מדף, צעד 1: באנר וספר ראשוןShelf, step 1: banner and first book

פרויקט מלווהCompanion project

זה הצעד הראשון בפרויקט שילווה אתכם כל הקורס. צרו את shelf.py שמדפיס: באנר עם שם האפליקציה, פרטים של ספר אחד שאתם אוהבים (שם, מחבר, מספר עמודים), ושורה "ספרים במדף: 1". בערך 10 שורות.

This is the first step of the project that accompanies you through the course. Create shelf.py that prints: a banner with the app name, details of one book you like (title, author, page count), and a line "Books on the shelf: 1". About 10 lines.

איך הפלט אמור להיראות?What should the output look like?
==============================
📚 מדף: הספרייה שלי
==============================

ספר ראשון:
  שם: הנסיך הקטן
  מחבר: אנטואן דה סנט-אכזופרי
  עמודים: 96

ספרים במדף: 1
==============================
📚 Shelf: my library
==============================

First book:
  Title: The Little Prince
  Author: Antoine de Saint-Exupéry
  Pages: 96

Books on the shelf: 1
shelf.py
רמזHint 1: התחילו בבאנר: קו, שם, קו.Start with the banner: a line, a name, a line.
רמזHint 2: מספר עמודים אפשר להדפיס כמספר אחרי פסיק: print("עמודים:", 96).Print the page count as a number after a comma: print("Pages:", 96).
רמזHint 3: רווחים בתחילת המחרוזת יוצרים "הזחה" יפה בפלט (בתוך המירכאות זה מותר!).Spaces at the start of a string make a nice indent in the output (inside the quotes that's allowed!).
לפתרוןSolution

אתגרים לחזקיםChallenges for the brave

אתגרChallenge 1

שעות ודקותHours and minutes

סרט ארוך 1000 דקות (סדרה שלמה בבינג'!). בלי לחשב בראש, הדפיסו כמה שעות שלמות זה וכמה דקות נשארות, בשורה אחת, למשל: 16 שעות ו-40 דקות.

A binge-watch is 1000 minutes long. Without doing the maths yourself, print how many whole hours that is and how many minutes remain, on one line, e.g. 16 hours and 40 minutes.

איך הפלט אמור להיראות?What should the output look like?
16 שעות ו- 40 דקות
16 hours and 40 minutes
main.py
רמזHint 1: שעות שלמות = כמה פעמים 60 נכנס ב-1000. איזה אופרטור נותן חילוק שלם?Whole hours = how many times 60 fits into 1000. Which operator gives whole division?
רמזHint 2: הדקות שנשארו הן השארית. איזה אופרטור נותן שארית?The leftover minutes are the remainder. Which operator gives a remainder?
רמזHint 3: print(1000 // 60, "...", 1000 % 60, "...")print(1000 // 60, "...", 1000 % 60, "...")
לפתרוןSolution
אתגרChallenge 2

פירמידת המספריםThe number pyramid

הדפיסו 5 שורות: 1 * 1, 11 * 11, 111 * 111 וכן הלאה עד 11111 * 11111. רק ש-Python תחשב! מה מיוחד בתוצאות? כתבו את התשובה בהערה בסוף הקוד.

Print 5 lines: 1 * 1, 11 * 11, 111 * 111 and so on up to 11111 * 11111. Let Python calculate! What's special about the results? Write the answer as a comment at the end of the code.

איך הפלט אמור להיראות?What should the output look like?
1
121
12321
1234321
123454321
main.py
רמזHint 1: כל שורה היא print של כפל אחד.Each line is a print of one multiplication.
רמזHint 2: הסתכלו על הספרות של כל תוצאה. הן עולות ואז יורדות.Look at the digits of each result. They go up and then down.
לפתרוןSolution

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