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

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

תנאיםConditions

if, elif, else, השוואות, and/or/not ואמת/שקר.

if, elif, else, comparisons, and/or/not and truthiness.

כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-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
s = 70
if s >= 90:
    print("A")
elif s >= 80:
    print("B")
else:
    print("C")

2. מה ערך הביטוי True and not False?What is True and not False?

3. איזה ערך הוא falsy?Which value is falsy?

תרגיליםExercises

תרגילExercise 1

זוגי או אי-זוגיEven or odd

קלטו מספר שלם והדפיסו even אם הוא זוגי ו-odd אם לא.

Read a whole number and print even if it's even, odd otherwise.

איך הפלט אמור להיראות?What should the output look like?
7
odd
main.py
רמזHint 1: זוגי = שארית 0 בחלוקה ל-2.Even = remainder 0 when divided by 2.
רמזHint 2: if n % 2 == 0:if n % 2 == 0:
לפתרוןSolution
תרגילExercise 2

ציון במיליםGrade in words

קלטו ציון (0-100) והדפיסו: 90+ excellent, 75-89 good, 55-74 pass, מתחת fail.

Read a score (0-100) and print: 90+ excellent, 75-89 good, 55-74 pass, below that fail.

איך הפלט אמור להיראות?What should the output look like?
82
good
main.py
רמזHint 1: מהגבוה לנמוך עם elif.From high to low with elif.
רמזHint 2: הסדר חשוב: בודקים 90 לפני 75.Order matters: check 90 before 75.
לפתרוןSolution
תרגילExercise 3

שנה מעוברתLeap year

קלטו שנה והדפיסו True אם היא מעוברת: מתחלקת ב-4, אבל לא ב-100, אלא אם היא מתחלקת ב-400.

Read a year and print True if it's a leap year: divisible by 4, but not by 100, unless divisible by 400.

איך הפלט אמור להיראות?What should the output look like?
2000
True
main.py
רמזHint 1: y % 4 == 0 and y % 100 != 0y % 4 == 0 and y % 100 != 0
רמזHint 2: or y % 400 == 0or y % 400 == 0
לפתרוןSolution
תרגילExercise 4

כניסה למערכתLog in

משתמש נכון: admin, סיסמה נכונה: py123. קלטו שם וסיסמה. אם שניהם נכונים הדפיסו welcome; אם רק השם נכון wrong password; אחרת unknown user.

Correct user: admin, password: py123. Read a name and password. If both are right print welcome; if only the name is right wrong password; otherwise unknown user.

איך הפלט אמור להיראות?What should the output look like?
admin
abc
wrong password
main.py
רמזHint 1: קודם בודקים את השם.Check the name first.
רמזHint 2: בתוך if השם, בודקים את הסיסמה.Inside the name's if, check the password.
לפתרוןSolution
תרגילExercise 5

מדף, צעד 5: תגית לספרShelf, step 5: tag a book

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

קלטו שם ספר, מספר עמודים ודירוג (1-5). הדפיסו <שם>: ואחריו תגית: ⭐ must read אם הדירוג 5, 📏 long אם יותר מ-500 עמודים (ודירוג פחות מ-5), אחרת 📖 regular.

Read a title, page count and rating (1-5). Print <title>: followed by a tag: ⭐ must read if rating is 5, 📏 long if over 500 pages (and rating under 5), otherwise 📖 regular.

איך הפלט אמור להיראות?What should the output look like?
Dune
600
4
Dune: 📏 long
shelf.py
רמזHint 1: שלושה קלטים, שניים מהם int.Three inputs, two of them int.
רמזHint 2: הסדר: דירוג 5 נבדק ראשון.Order: rating 5 is checked first.
לפתרוןSolution

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

אתגרChallenge 1

סוג משולשTriangle type

קלטו שלוש צלעות. אם הן לא יכולות ליצור משולש (צלע אחת ≥ סכום שתי האחרות) הדפיסו invalid. אחרת: equilateral (שלוש שוות), isosceles (שתיים), scalene (אף אחת).

Read three sides. If they can't form a triangle (one side ≥ the sum of the other two) print invalid. Otherwise: equilateral (all equal), isosceles (two), scalene (none).

איך הפלט אמור להיראות?What should the output look like?
5
5
8
isosceles
main.py
רמזHint 1: בודקים invalid ראשון.Check invalid first.
רמזHint 2: a == b == c לשלוש שוות.a == b == c for all equal.
רמזHint 3: a == b or b == c or a == c לשתיים.a == b or b == c or a == c for two.
לפתרוןSolution
אתגרChallenge 2

אבן, נייר, מספרייםRock, paper, scissors

קלטו שתי בחירות (rock / paper / scissors) של שחקן 1 ושחקן 2. הדפיסו tie, player 1 או player 2 לפי המנצח.

Read two choices (rock / paper / scissors) for player 1 and player 2. Print tie, player 1 or player 2 for the winner.

איך הפלט אמור להיראות?What should the output look like?
Rock
paper
player 2
main.py
רמזHint 1: תיקו קודם.Tie first.
רמזHint 2: שלושה מצבים שבהם שחקן 1 מנצח, מחוברים ב-or.Three cases where player 1 wins, joined with or.
לפתרוןSolution

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