求大神帮忙做一道Python题,简易程序,Python2.7.13
发布网友
发布时间:2022-05-18 12:17
我来回答
共1个回答
热心网友
时间:2023-10-16 11:31
#!/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 '请输入正确分数'
if __name__ == '__main__':
student_num,anum = input(u'请输入学生学号及考试成绩,以英文逗号相隔:')
result = lev(anum)
if result not in 'ABCDE':
print result
else:
print u'学生{0}的成绩的等级是:{1}'.format(student_num, result)