我創建了一個計算程序,計算出一個等級,並吐出一條消息,如「你有一個(如果百分比超過90),b如果超過80等百分比..我不是。?!使用運營商正確地有人請告訴我正確的格式感謝布爾操作符<, >,<=等
def totals(score_w, score_x, score_y, score_z):
print ("Overall percentage = ", round(score_w + score_x + score_y + score_z), 1)
if round((score_w + score_x + score_y + score_z, 1) > 90.0):
print("Your grade will be at least: A")
elif round((score_w + score_x + score_y + score_z, 1) (< 90) and (>= 80)):
print("Your grade will be at least: B")
elif round((score_w + score_x + score_y + score_z, 1) (< 80) and (>= 70)):
print("Your grade will be at least: C")
把'round((score_w + score_x + score_y + score_z,1)'放在一個變量中,所以你不必一直重複它,然後重寫你的'if's來使用這個變量。變得更清晰 – Ryan