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

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

משתנים, print ו-inputVariables, print & input

משתנים כתוויות על ערכים, קלט מהמשתמש, f-strings ראשונים.

Variables as labels on values, user input, first f-strings.

כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-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
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!
main.py
רמזHint 1: name = input("...")name = input("...")
רמזHint 2: print(f"... {name}!")print(f"... {name}!")
לפתרוןSolution
תרגיל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?
3 7
main.py
רמז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.
לפתרוןSolution
תרגיל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
main.py
רמזHint 1: שני input לשני משתנים.Two input calls, two variables.
רמזHint 2: שתי שורות print עם f-string.Two print lines with f-strings.
לפתרוןSolution
תרגילExercise 4

תאריך עם sepA 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?
19/11/2026
main.py
רמזHint 1: print(day, month, year, sep=...)print(day, month, year, sep=...)
לפתרוןSolution
תרגיל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
--------------------
shelf.py
רמזHint 1: title = input(...) ו-author = input(...).title = input(...) and author = input(...).
רמזHint 2: קו: print("-" * 20) או מחרוזת מקפים.A line: a string of dashes.
לפתרוןSolution

אתגרים לחזקים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
main.py
רמזHint 1: שלוש קריאות ל-input.Three input calls.
רמזHint 2: f-string אחת עם שלושה {}.One f-string with three {}.
לפתרוןSolution
אתגר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?
2 3 1
main.py
רמזHint 1: החלפה של שניים היא a, b = b, a. אותו רעיון עם שלושה.Swapping two is a, b = b, a. Same idea with three.
לפתרוןSolution

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