自己动手敲的小程序

输入两个数,输出二者中最大的那个

def max(a,b):
    if a>b:
        print(a)
    else:
        print(b)
num1 = int(input("请输入第一个数字:"))
num2 = int(input("请输入第二个数字:"))
max(num1,num2)


判断学生的成绩,并分等级

score = int(input("请输入一个学生的成绩:"))
if(score >= 0 and score <60):
    print("E")
elif (score>=60 and score<=69):
    print("D")
elif (score>=70 and score<=79):
    print("C")
elif (score>=80 and score<=89):


    print("B")
elif(score>=90 and score<=100):
    print("A")
elif (score <0 or score >100):
    print("请重新输入")




循环输入

while(True):
    score = int(input("请输入一个学生的成绩:"))
    if(score >= 0 and score <60):
        print("E")
    elif (score>=60 and score<=69):
        print("D")
    elif (score>=70 and score<=79):
        print("C")
    elif (score>=80 and score<=89):
    
        print("B")
    elif(score>=90 and score<=100):
        print("A")
    elif (score <0 or score >100):
        print("请重新输入")



1-100间所有偶数的和

sum = 0
for i in range(1,101):
    if i % 2 == 0:
        sum = sum + i
        i  = i + 1
    else:
        i = i + 1
print(sum)


猜你喜欢

转载自blog.csdn.net/nowfuture/article/details/78260605