جواب «Step 3: The Honesty Label» چالش 3 از جلسهی 48
سؤال
honesty_label(parts): هر بخش یک (part, who) است و who یکی از "ai"، "me"، "both". بخشها را در دیکشنری groups جدا کن و چاپ کن:AI wrote: the answers in the chat, the page coloursI wrote: the handout, words() and score(), the attack testWe wrote together: the safe calculatorwritten only by me: 50 %
راهنما
groups[who].append(part) و برای چاپ ", ".join(groups["ai"]).
یک جواب درست
def honesty_label(parts):
groups = {"ai": [], "me": [], "both": []}
for part, who in parts:
groups[who].append(part)
print("AI wrote:", ", ".join(groups["ai"]))
print("I wrote:", ", ".join(groups["me"]))
print("We wrote together:", ", ".join(groups["both"]))
mine = len(groups["me"]) * 100 // len(parts)
print("written only by me:", mine, "%")
# ---- test (do not change) ----
honesty_label([
("the handout", "me"),
("words() and score()", "me"),
("the safe calculator", "both"),
("the answers in the chat", "ai"),
("the attack test", "me"),
("the page colours", "ai"),
])
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن