بتل کد Battle Codeدارد باز می‌شود…

Best and Lowest چالش 4 از جلسه‌ی 10، متوسط

اپ نمره: کادر Score و دکمه‌ی Add. تابع add را کامل کن: نمره را به شکل عدد در scores بگذار، کادر را خالی کن، و دو متن را بنویس: Best: 12 (بیشترین) و Lowest: 7 (کمترین). مثلاً ۹، ۱۲ و ۷ ← Best: 12 و Lowest: 7. (حرف و کادر خالی را در این تمرین نمی‌زنیم.)

import app

scores = []

def add():
    # 1) put the score in the list as a number
    # 2) empty the box
    # 3) show the best and the lowest score
    pass

app.title("My Scores")
score = app.number("Score")
app.button("Add", add)
best = app.text("Best: -")
low = app.text("Lowest: -")
app.run()

راهنما و جواب این چالش · برگشت به درس جلسه‌ی 10: حساب · چالش بعدی: Number or Error?

بیشتر بخوان: تابع در پایتون: آموزش def، پارامتر و return با مثال