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

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

טיפוסים ומספריםTypes & numbers

int, float, bool, המרות בין טיפוסים, עיגול, ומה קורה כשמערבבים.

int, float, bool, converting between types, rounding, and what happens when you mix them.

כותבים בעורך שבכל תרגיל, לוחצים הרצה כדי לראות פלט, ובדיקה כדי שהבודק האוטומטי יבדוק. אפשר גם לעבוד ב-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. מה הטיפוס של 7 / 7?What is the type of 7 / 7?

2. מה ידפיס הקוד?What does this print?
python
x = input()   # user types 3
print(x * 2)

3. איך מקבלים 412 עמודים חלקי 30 עמודים ביום, מעוגל למעלה?How do you get 412 pages / 30 per day, rounded up?

תרגיליםExercises

תרגילExercise 1

גיל בעוד 10 שניםAge in 10 years

קלטו גיל והדפיסו את הגיל בעוד 10 שנים.

Read an age and print the age in 10 years.

איך הפלט אמור להיראות?What should the output look like?
גיל: 31
41
Age: 31
41
main.py
רמזHint 1: int(input(...))int(input(...))
רמזHint 2: מוסיפים 10.Add 10.
לפתרוןSolution
תרגילExercise 2

צלזיוס לפרנהייטCelsius to Fahrenheit

קלטו טמפרטורה בצלזיוס (יכולה להיות עשרונית) והדפיסו בפרנהייט, מעוגל לספרה אחת אחרי הנקודה. נוסחה: F = C × 9/5 + 32.

Read a Celsius temperature (may be a decimal) and print it in Fahrenheit, rounded to one decimal. Formula: F = C × 9/5 + 32.

איך הפלט אמור להיראות?What should the output look like?
°C: 36.6
97.9
main.py
רמזHint 1: float(input(...))float(input(...))
רמזHint 2: round(f, 1)round(f, 1)
לפתרוןSolution
תרגילExercise 3

בלש טיפוסיםType detective

הדפיסו את הטיפוס של ארבעה ערכים: 12, 12.0, "12" ו-12 > 5, כל אחד בשורה.

Print the type of four values: 12, 12.0, "12" and 12 > 5, one per line.

איך הפלט אמור להיראות?What should the output look like?
<class 'int'>
<class 'float'>
<class 'str'>
<class 'bool'>
main.py
רמזHint 1: print(type(...)) ארבע פעמים.print(type(...)) four times.
לפתרוןSolution
תרגילExercise 4

חלוקת חשבוןSplit the bill

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

Read a bill total and a number of diners. Print each person's share with exactly 2 decimals.

איך הפלט אמור להיראות?What should the output look like?
סכום: 250
סועדים: 3
83.33
Total: 250
Diners: 3
83.33
main.py
רמזHint 1: סכום ב-float, סועדים ב-int.Total as float, diners as int.
רמזHint 2: f"{share:.2f}"f"{share:.2f}"
לפתרוןSolution
תרגילExercise 5

מדף, צעד 3: אחוז התקדמותShelf, step 3: reading progress

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

קלטו כמה עמודים יש בספר וכמה קראתם. הדפיסו את אחוז ההתקדמות כמספר שלם (מעוגל) ואחריו %, וגם כמה ימים נשארו בקצב של 20 עמודים ביום (מעוגל למעלה).

Read a book's total pages and pages read. Print the progress as a whole percent followed by %, and how many days are left at 20 pages a day (rounded up).

איך הפלט אמור להיראות?What should the output look like?
עמודים בספר: 412
קראתי: 103
25%
ימים שנשארו: 16
Total pages: 412
Pages read: 103
25%
Days left: 16
shelf.py
רמזHint 1: אחוז: round(read / pages * 100).Percent: round(read / pages * 100).
רמזHint 2: ימים: math.ceil((pages - read) / 20).Days: math.ceil((pages - read) / 20).
לפתרוןSolution

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

אתגרChallenge 1

שניות לשעוןSeconds to clock

קלטו מספר שניות והדפיסו בפורמט H:MM:SS, למשל 3725 → 1:02:05.

Read a number of seconds and print it as H:MM:SS, e.g. 3725 → 1:02:05.

איך הפלט אמור להיראות?What should the output look like?
3725
1:02:05
main.py
רמזHint 1: // ו-% עם 3600 ו-60.// and % with 3600 and 60.
רמזHint 2: {m:02d} מוסיף אפס מוביל.{m:02d} adds a leading zero.
לפתרוןSolution
אתגרChallenge 2

ריבית דריביתCompound interest

קלטו סכום ואחוז ריבית שנתי. הדפיסו את הסכום אחרי 3 שנים של ריבית דריבית, מעוגל ל-2 ספרות. נוסחה: סכום × (1 + ריבית/100) בחזקת 3.

Read an amount and an annual interest percent. Print the amount after 3 years of compound interest, rounded to 2 places. Formula: amount × (1 + rate/100) to the power of 3.

איך הפלט אמור להיראות?What should the output look like?
1000
5
1157.63
main.py
רמזHint 1: ** לחזקה.** for power.
רמזHint 2: round(x, 2)round(x, 2)
לפתרוןSolution

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