יש יותר מדרך נכונה אחת. אם הבדיקות עוברות, גם הפתרון שלכם נכון.There is more than one right way. If the checks pass, your solution is right too.
מחווןRubric (25 נקודותpoints)
כשכל הבדיקות עוברות, כל השורות מסומנות. אם לא, סמנו בעצמכם מה כן עשיתם נכון.When every check passes, all rows are ticked. If not, tick what you did get right.
שאלהQuestion 6
ראשי תיבותInitials
כתבו initials(full_name) שמחזירה ראשי תיבות באותיות גדולות עם נקודות: "ada lovelace" → "A.L.". רווחים כפולים לא יוצרים נקודה ריקה.
Write initials(full_name) returning capital initials with dots: "ada lovelace" → "A.L.". Double spaces don't create an empty dot.
איך הפלט אמור להיראות?What should the output look like?
A.L. G.V.R.
main.py
רמזHint 1:split() בלי ארגומנט מתעלם מרווחים כפולים.split() without an argument ignores double spaces.
הפתרון שלנוOur solution
main.py
def initials(full_name):return"".join(word[0].upper() +"."for word in full_name.split())
print(initials("ada lovelace"), initials(" guido van rossum "))
פלטOutput
A.L. G.V.R.
יש יותר מדרך נכונה אחת. אם הבדיקות עוברות, גם הפתרון שלכם נכון.There is more than one right way. If the checks pass, your solution is right too.
מחווןRubric (25 נקודותpoints)
כשכל הבדיקות עוברות, כל השורות מסומנות. אם לא, סמנו בעצמכם מה כן עשיתם נכון.When every check passes, all rows are ticked. If not, tick what you did get right.
שאלהQuestion 7
מחשבון חשבוןA bill calculator
קלט: שורה ראשונה סכום החשבון, שנייה מספר הסועדים, שלישית אחוז טיפ. הדפיסו Each pays: X כש-X מעוגל לשתי ספרות (בפורמט .2f). אם מספר הסועדים 0 או פחות, הדפיסו Need at least one person.
Input: the first line is the bill, the second the number of diners, the third a tip percent. Print Each pays: X with X to two decimals (format .2f). If the number of diners is 0 or less, print Need at least one person.
איך הפלט אמור להיראות?What should the output look like?
רמזHint 2:total = bill * (1 + tip / 100).total = bill * (1 + tip / 100).
הפתרון שלנוOur solution
main.py
bill =float(input())
people =int(input())
tip =float(input())
if people <=0:print("Need at least one person")
else:
total = bill * (1+ tip /100)
print(f"Each pays: {total / people:.2f}")
פלטOutput
100
3
15
Each pays: 38.33
יש יותר מדרך נכונה אחת. אם הבדיקות עוברות, גם הפתרון שלכם נכון.There is more than one right way. If the checks pass, your solution is right too.
מחווןRubric (30 נקודותpoints)
כשכל הבדיקות עוברות, כל השורות מסומנות. אם לא, סמנו בעצמכם מה כן עשיתם נכון.When every check passes, all rows are ticked. If not, tick what you did get right.