בית Home › חלק Part 1: יסודות Foundations › מפגש Session 2 › תרגול Practice
סקירה Overview הרצאה Lecture מצגת Slides תרגול Practice פתרונות Solutions סיכום Summary מדריך טכני Tech guide כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-VS Code. ההתקדמות נשמרת. Write in each exercise's editor, press Run to see output and Check for the automatic checker. You can also work in VS Code. Progress is saved.
חימום: 3 שאלות Warm-up: 3 questions 1. מה ידפיס הקוד? What does this print? python העתקה Copy
x = 5
x = x + 3
print (x)
2. מה הטיפוס של מה ש-input מחזירה? What type does input return?
3. איזה שם משתנה תקין ומקובל? Which variable name is valid and conventional?
תרגילים Exercises תרגיל Exercise 1ברכה אישית Personal greeting
קלטו שם עם input והדפיסו שלום, <שם>! (באנגלית: Hello, <name>!). השתמשו ב-f-string.
Read a name with input and print Hello, <name>!. Use an f-string.
איך הפלט אמור להיראות? What should the output look like? מה שמך? Dana
שלום, Dana! Your name? Dana
Hello, Dana!
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: name = input("...")name = input("...")
רמז Hint 2: print(f"... {name}!")print(f"... {name}!")
רמז Hint 0/2
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
תרגיל Exercise 2החלפת ערכים Swap values
נתונים a = 7 ו-b = 3. החליפו ביניהם כך שבסוף a הוא 3 ו-b הוא 7, והדפיסו את שניהם.
Given a = 7 and b = 3, swap them so that a is 3 and b is 7, then print both.
איך הפלט אמור להיראות? What should the output look like?
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: אפשר משתנה עזר: temp = a. You can use a helper: temp = a.
רמז Hint 2: או בשורה אחת: a, b = b, a. Or in one line: a, b = b, a.
רמז Hint 0/2
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
תרגיל Exercise 3כרטיס היכרות Intro card
קלטו שם ועיר (שתי שאלות), והדפיסו שתי שורות: שם: ... ו-עיר: ....
Read a name and a city (two questions) and print two lines: Name: ... and City: ....
איך הפלט אמור להיראות? What should the output look like? שם: Noa
עיר: Eilat
שם: Noa
עיר: Eilat Name: Noa
City: Eilat
Name: Noa
City: Eilat
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: שני input לשני משתנים. Two input calls, two variables.
רמז Hint 2: שתי שורות print עם f-string. Two print lines with f-strings.
רמז Hint 0/2
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
תרגיל Exercise 4תאריך עם sep A date with sep
משתנים day = 19, month = 11, year = 2026. הדפיסו בשורה אחת 19/11/2026 בעזרת sep, בלי לכתוב / בתוך מחרוזת אחרת.
Variables day = 19, month = 11, year = 2026. Print 19/11/2026 on one line using sep, without writing / in any other string.
איך הפלט אמור להיראות? What should the output look like?
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: print(day, month, year, sep=...)print(day, month, year, sep=...)
רמז Hint 0/1
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
תרגיל Exercise 5מדף, צעד 2: ספר מהמשתמש Shelf, step 2: a book from the user פרויקט מלווה Companion project
שאלו את המשתמש על שם ספר ועל המחבר, והדפיסו כרטיס: קו, 📚 <שם>, ✍️ <מחבר>, קו. שמרו כל ערך במשתנה עם שם טוב.
Ask the user for a book title and author, and print a card: a line, 📚 <title>, ✍️ <author>, a line. Keep each value in a well-named variable.
איך הפלט אמור להיראות? What should the output look like? שם הספר: Dune
מחבר: Frank Herbert
--------------------
📚 Dune
✍️ Frank Herbert
-------------------- Book title: Dune
Author: Frank Herbert
--------------------
📚 Dune
✍️ Frank Herbert
--------------------
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: title = input(...) ו-author = input(...).title = input(...) and author = input(...).
רמז Hint 2: קו: print("-" * 20) או מחרוזת מקפים. A line: a string of dashes.
רמז Hint 0/2
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
אתגרים לחזקים Challenges for the brave אתגר Challenge 1סיפור משוגע Mad-libs story
קלטו שלוש מילים: חיה, צבע, מקום. הדפיסו משפט אחד שמשלב את שלושתן בסדר הזה, למשל ראיתי זברה סגולה בירושלים.
Read three words: an animal, a colour, a place. Print one sentence using all three in that order, e.g. I saw a purple zebra in Paris.
איך הפלט אמור להיראות? What should the output look like? חיה: zebra
צבע: purple
מקום: Paris
ראיתי zebra purple ב-Paris Animal: zebra
Colour: purple
Place: Paris
I saw a zebra purple in Paris
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: שלוש קריאות ל-input. Three input calls.
רמז Hint 2: f-string אחת עם שלושה {}. One f-string with three {}.
רמז Hint 0/2
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)
אתגר Challenge 2סיבוב שלושה Rotate three
a, b, c = 1, 2, 3. בשורה אחת בלבד, סובבו כך ש-a יקבל את הערך של b, b של c ו-c של a. הדפיסו 2 3 1.
a, b, c = 1, 2, 3. In a single line, rotate so a gets b's value, b gets c's and c gets a's. Print 2 3 1.
איך הפלט אמור להיראות? What should the output look like?
בדיקה Check הרצה Run איפוס Reset
רמז Hint 1: החלפה של שניים היא a, b = b, a. אותו רעיון עם שלושה. Swapping two is a, b = b, a. Same idea with three.
רמז Hint 0/1
לפתרון Solution פתרון ויזואלי בסימולציה Visual solution (animated)