Python basic algorithm collection (12)-conditions to determine which grade the input score belongs to

According to the grade used for input, it is judged which grade the grade belongs to.

This program uses the custom function CJ() to judge. When the score is greater than 90, it belongs to A, etc., when the score is between 60 and 90, enter B, etc., and down from 60 to C, etc., the code is as follows:

def CJ(n):
    if (n>=90):
        print('{}分属于A等'.format(n))
    elif (60<=n<=89):
        print('{}分属于B等'.format(n))
    else:
        print('{}分属于C等'.format(n))

n=float(input('请输入成绩'))
CJ(n)

The implementation effect is as follows:

 

Guess you like

Origin blog.csdn.net/weixin_43115314/article/details/114248947