מה זה תכנות? התקנה וטרמינל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
תרגילים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.
הדפיסו כרטיס ביקור של 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().
בקוד הזה יש 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.
קניתם 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?
מדף, צעד 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!).
סרט ארוך 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?
הדפיסו 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.