جواب «Game Scoreboard» چالش 8 از جلسهی 7
سؤال
تابلوی امتیاز یک بازی بساز. دو متغیر داری: score (امتیاز کل) و rounds (شمارهی دور)، هر دو از 0. سه دور بنویس؛ در هر دور: امتیاز این دور را (عدد صحیح) از ورودی بگیر، آن را به score اضافه کن، یکی به rounds اضافه کن و چاپ کن Round 1: 10 points. مثال: برای ورودیهای 10 و 5 و 20 خروجی این سه خط است: Round 1: 10 points و Round 2: 15 points و Round 3: 35 points. حالا یک تابلوی امتیاز واقعی داری که حساب همهچیز را نگه میدارد!
راهنما
هر دور چهار خط دارد: گرفتن امتیاز با int(input(...))، score = score + points، rounds = rounds + 1 و چاپ. ترتیب مهم است: اول اضافه کن، بعد چاپ کن.
یک جواب درست
score = 0
rounds = 0
points = int(input("Points: "))
score = score + points
rounds = rounds + 1
print(f"Round {rounds}: {score} points")
points = int(input("Points: "))
score = score + points
rounds = rounds + 1
print(f"Round {rounds}: {score} points")
points = int(input("Points: "))
score = score + points
rounds = rounds + 1
print(f"Round {rounds}: {score} points")
اول خودت امتحان کن؛ جوابهای دیگر هم قبول است. برگرد و خودت حلش کن