python简单地实现几个小代码

#一到一百相加的和:
def sum():
    sum = 0
    for n in range(1, 101):
        sum = sum + n
    return sum

print('一到一百相加的和是:',sum())


#一到一百偶数相加的和:
he=0
for i in range(0,100,2):
    he+=i
print(he)


#输入成绩判断等级:

cj=float (input("请输入你的成绩:"))
if cj>=90 and cj<=100:
    print("优秀")
elif cj>=70 and cj<90:
    print("良好")
elif cj>=60 and cj<70:
    print("及格")
else:
    print("你要努力了")


咯咯,第一次写这玩意==


你可能感兴趣的:(python简单地实现几个小代码)