题目一:代码
count = 0 for i in range(1,5): for j in range(1,5): for k in range(1,5): if i != j and i != k and j != k: print("%d%d%d"%(i,j,k),end=' ') count = count + 1 print("总的数字:%d"%count)
题目二:代码
student = int(input('请输入你的成绩:')) if student >= 90: print('你的成绩非常优秀!') pass elif student >= 80: print('你的成绩可以有提升空间') pass elif student >= 70: print('你的成绩需要努力了') pass elif student >= 60: print('你的成绩不太行') pass else: print('加油') pass print("程序结束符.......:")
题目三:代码
time = 0 while time <= 3: age = int(input('请输入你的年龄->:')) if age == 17: print('恭喜你猜对了') break pass elif age >= 17: print('猜大了') pass else: print('猜小了') pass time += 1 if time == 3: character = str(input('想不想重新输入Y或者N:')) if character == 'Y' or character == 'y': time = 0 pass elif character == 'N' or character == 'n': time = 4 # 大于表达式的值退出 pass else: print('请输入正确的标记蟹蟹') pass
题目四:代码
count = 0 while count <= 3: Height = float(input('请输入你的身高:..')) # 1.75 = 175cm Weight = float(input('请输入你的体重:..')) BMI = Weight / (Height ** 2) print('你的BMI是:%3.f'%BMI) if BMI <= 14.5: print('张三,你的营养不够,需要加强') pass elif BMI <= 17.5: print('张三兄弟你的营养过轻,还是再去补补') pass elif BMI <= 19.5: print('张三兄弟不错,很标准!') pass else: print('张三要学会控制自己') count = count + 1 pass
题目五:代码
row = 1 # 行 while row <= 9: col = 1 # 列 while col <= row: print("%d*%d=%d" % (col,row,row*col),end=" ") # print自身换行 end是空格 col += 1 # col = col + 1 ,因为这个col会进行再次进行1,然后列等于行,到2时候就会进行两次while循环,然后跳出 pass print() row += 1 pass