טיפוסים ומספריםTypes & numbers
int, float, bool, המרות בין טיפוסים, עיגול, ומה קורה כשמערבבים.
int, float, bool, converting between types, rounding, and what happens when you mix them.
גיל בעוד 10 שניםAge in 10 years
תזכורת: מה ביקשוReminder: the task
קלטו גיל והדפיסו את הגיל בעוד 10 שנים.
Read an age and print the age in 10 years.
הפתרון המלא והפלט שלוFull solution and its output
age = int(input("גיל: "))
print(age + 10)age = int(input("Age: "))
print(age + 10)גיל: 31 41
Age: 31 41
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
צלזיוס לפרנהייטCelsius to Fahrenheit
תזכורת: מה ביקשוReminder: the task
קלטו טמפרטורה בצלזיוס (יכולה להיות עשרונית) והדפיסו בפרנהייט, מעוגל לספרה אחת אחרי הנקודה. נוסחה: 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.
הפתרון המלא והפלט שלוFull solution and its output
c = float(input("°C: "))
f = c * 9 / 5 + 32
print(round(f, 1))°C: 36.6 97.9
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
בלש טיפוסיםType detective
תזכורת: מה ביקשוReminder: the task
הדפיסו את הטיפוס של ארבעה ערכים: 12, 12.0, "12" ו-12 > 5, כל אחד בשורה.
Print the type of four values: 12, 12.0, "12" and 12 > 5, one per line.
הפתרון המלא והפלט שלוFull solution and its output
print(type(12))
print(type(12.0))
print(type("12"))
print(type(12 > 5))<class 'int'> <class 'float'> <class 'str'> <class 'bool'>
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
חלוקת חשבוןSplit the bill
תזכורת: מה ביקשוReminder: the task
קלטו סכום חשבון ומספר סועדים. הדפיסו כמה כל אחד משלם, עם בדיוק 2 ספרות אחרי הנקודה.
Read a bill total and a number of diners. Print each person's share with exactly 2 decimals.
הפתרון המלא והפלט שלוFull solution and its output
total = float(input("סכום: "))
people = int(input("סועדים: "))
share = total / people
print(f"{share:.2f}")total = float(input("Total: "))
people = int(input("Diners: "))
share = total / people
print(f"{share:.2f}")סכום: 250 סועדים: 3 83.33
Total: 250 Diners: 3 83.33
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
מדף, צעד 3: אחוז התקדמותShelf, step 3: reading progress
תזכורת: מה ביקשוReminder: the task
קלטו כמה עמודים יש בספר וכמה קראתם. הדפיסו את אחוז ההתקדמות כמספר שלם (מעוגל) ואחריו %, וגם כמה ימים נשארו בקצב של 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).
הפתרון המלא והפלט שלוFull solution and its output
import math
pages = int(input("עמודים בספר: "))
read = int(input("קראתי: "))
percent = round(read / pages * 100)
days = math.ceil((pages - read) / 20)
print(f"{percent}%")
print(f"ימים שנשארו: {days}")import math
pages = int(input("Total pages: "))
read = int(input("Pages read: "))
percent = round(read / pages * 100)
days = math.ceil((pages - read) / 20)
print(f"{percent}%")
print(f"Days left: {days}")עמודים בספר: 412 קראתי: 103 25% ימים שנשארו: 16
Total pages: 412 Pages read: 103 25% Days left: 16
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
שניות לשעוןSeconds to clock
תזכורת: מה ביקשוReminder: the task
קלטו מספר שניות והדפיסו בפורמט 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.
הפתרון המלא והפלט שלוFull solution and its output
total = int(input())
h = total // 3600
m = total % 3600 // 60
s = total % 60
print(f"{h}:{m:02d}:{s:02d}")3725 1:02:05
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.
ריבית דריביתCompound interest
תזכורת: מה ביקשוReminder: the task
קלטו סכום ואחוז ריבית שנתי. הדפיסו את הסכום אחרי 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.
הפתרון המלא והפלט שלוFull solution and its output
amount = float(input())
rate = float(input())
final = amount * (1 + rate / 100) ** 3
print(round(final, 2))1000 5 1157.63
יש יותר מדרך נכונה אחת. אם הפלט שלכם זהה, גם הפתרון שלכם נכון.There is more than one right way. If your output matches, your solution is right too.