分类 python 下的文章

1、选择题部分

print("BBCAA") # 1-5
print("ABCAD") # 6-10
print("DCCDB") # 11-15
print("ACCDC") # 16-20

2、小明的零花钱

a = input()
b = input()
c = int(a)+int(b)
d = float(c/6)
print(round(d,1))

3、小明的期中考成绩

a = input()
b = input()
c = input()
if int(a)+int(b)+int(c) >= 360 :
    print('happy')
else:
    print('sad')

4、会考等级

a = float(input())
if a >= 90:
    print('优秀')
elif a >= 60:
    print('合格')
else:
    print('不合格')

5、阿拉丁的宝箱

a = input()
b = input()
if a == "183" and b == "680":
    print('success')
if a == '183' and b != '680':
    print('B is wrong')
if a != '183' and b == "680":
    print('A is wrong')

特别说明第五题用if--elif的写法:

a = input()
b = input()
if a == "183" and b == "680":
    print('success')
elif a == '183' and b != '680':
    print('B is wrong')
elif a != '183' and b == "680":
    print('A is wrong')

(仅把后两个‘if’改为‘elif’)