score函數(shù)的公式?
def main(): score = float(input('請(qǐng)輸入成績(jī): ')
) if score >= 90: grade = 'A' elif score >= 80: grade = 'B' elif score >= 70: grade = 'C' elif score >= 60: grade = 'D' else: grade = 'E' print('對(duì)應(yīng)的等級(jí)是:', grade) if __name__ == '__main__': main() 2、也可以將五分制構(gòu)造出一個(gè)字符串'EEEEEEDCBAA',用以下方法實(shí)現(xiàn)這個(gè)功能:
score = int(input()) degree = 'EEEEEEDCBAA' if (score > 100 or score < 0): print('Data error!'
) else: print(degree[score//10])
上一篇是否有聲音輸出