Python第三周作业节选
n = int(input()) # n范围内的立方数 list_cube = [0] # 用于存储立方数的列表 for i in range(1, n + 1): list_cube.append(i * i * i) for a in range(6, n + 1): for b in range(2, a - 1): if list_cube[a] < (list_cube[b] + list_cube[b + 1] + list_cube[b + 2]): break for c in range(b + 1, a): if list_cube[a] < (list_cube[b] + list_cube[c] + list_cube[c + 1]): break for d in range(c + 1, a): if list_cube[a] == (list_cube[b] + list_cube[c] + list_cube[d]): print("Cube = %d,Tripe = (%d,%d,%d)" % (a, b, c, d))
N=eval(input()) for i in range (N): a=eval(input()) if (a % 2 != 0): max=min=0 elif (a % 4) == 0: max = a / 2 min = a / 4 else: max = a / 2 min = (a /4)+(a%4)/2 print ("%d %d"%(min,max))
try: TempStr = input("") if TempStr[-1] in ['F','f']: C = (eval(TempStr[0:-1]) - 32) / 1.8 print("{:.2f}C"/format(C)) elif TempStr[-1] in ['C','c']: F = 1.8 * eval(TempStr[0:-1]) + 32 print("{:.2f}F".format(F)) else: print("输入错误,末位只能是'C','c','F','f'") except NameError : print("试图访问的变量名不存在") except SyntaxError: print('存在语法错误')