求大神帮忙做一道Python题,简易程序,Python2.7.13

Python2.7.13 尽量做得完美, 对了给财富值
2024-11-22 22:55:57
推荐回答(1个)
回答(1):

#!/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)