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

PythonPython

מבחן 1: יסודותExam 1: Basics

משתנים, טיפוסים, מחרוזות, תנאים וקלט

Variables, types, strings, conditions and input

60 דקותminutes4 שאלות בחירהmultiple choice3 שאלות קודcoding questions100 נקודותpoints
60:00השעון רק עוזר להתאמן. אפשר גם בלי.The timer is just for practice. You can skip it.

חלק א: שאלות בחירה (5 נקודות לשאלה)Part A: multiple choice (5 points each)

התשובות מתגלות רק כשמסיימים את המבחן.Answers are revealed only when you finish the exam.

1. מה יודפס?What is printed? 5
python
print("3" + "4")
2. מה הטיפוס של 7 / 2?What's the type of 7 / 2? 5
3. מה יודפס?What is printed? 5
python
word = "python"
print(word[1:4])
4. מתי יודפס B?When is B printed? 5
python
if x > 10:
    print("A")
elif x > 5:
    print("B")
else:
    print("C")

חלק ב: שאלות קודPart B: coding questions

שאלהQuestion 5

ציון אותA letter grade

כתבו letter(score): 90 ומעלה "A", 80–89 "B", 70–79 "C", אחרת "F". ציון מחוץ לטווח 0–100 מחזיר "?".

Write letter(score): 90 and up "A", 80–89 "B", 70–79 "C", otherwise "F". A score outside 0–100 returns "?".

איך הפלט אמור להיראות?What should the output look like?
A B F ?
main.py
רמזHint 1: בדקו קודם את הטווח.Check the range first.
הפתרון שלנוOur solution
main.py
def letter(score):
    if score < 0 or score > 100:
        return "?"
    if score >= 90:
        return "A"
    if score >= 80:
        return "B"
    if score >= 70:
        return "C"
    return "F"

print(letter(95), letter(80), letter(12), letter(101))
פלטOutput
A B F ?

יש יותר מדרך נכונה אחת. אם הבדיקות עוברות, גם הפתרון שלכם נכון.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?
100
3
15
Each pays: 38.33
main.py
רמזHint 1: float(input()), int(input()).float(input()), int(input()).
רמז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.

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