defmain():score=float(input('請輸入成績:')
)ifscore>=90:grade='A'elifscore>=80:grade='B'elifscore>=70:grade='C'elifscore>=60:grade='D'else:grade='E'print('對應的等級是:',grade)if__name__=='__main__':main()2、也可以將五分制構造出一個字符串'EEEEEEDCBAA',用以下方法實現這個功能:
score=int(input())degree='EEEEEEDCBAA'if(score>100orscore<0):print('Dataerror!'
)else:print(degree[score//10])