期末作业,用python做单科成绩分析器
发布网友
发布时间:2022-04-26 04:20
我来回答
共1个回答
热心网友
时间:2022-04-18 08:19
#!/usr/bin/python
# -*- coding:utf-8 -*-
def lev(num):
atype = isinstance(num, (int, float, long))
if atype is True:
if 90 <= num <= 100:
return 'A'
elif 80 <= num < 90:
return 'B'
elif 70 <= num < 80:
return 'C'
elif 60 <= num < 70:
return 'D'
elif num < 60:
return 'E'
else:
return u'请输入正确分数'
if __name__ == '__main__':
anum = input(u'请输入考试成绩:')
result = lev(anum)
if result not in 'ABCDE':
print result
else:
print u'输入成绩的等级是:{}'.format(result)