python第三章習(xí)題
3.1earth_weight = float(input("請(qǐng)輸入你現(xiàn)在在地球上的體重(kg): ")) print("年份\t地球體重(kg)\t月球體重(kg)") for year in range(1, 11): earth_weight += 0.5 moon_weight = earth_weight * 0.165 print(f"{year}\t{earth_weight:.2f}\t\t{moon_weight:.2f}")
3.2ability = 1 for day in range(1, 366): if (day - 1) % 7 < 3: ability = ability else: ability *= 1.01 print(f"連續(xù)學(xué)習(xí)365天后能力值是{ability:.4f}")
3.3
ability = 1 for day in range(1, 366): if day % 10 != 0: if (day - 1) % 7 < 3: ability = ability else: ability *= 1.01 else: ability = ability print(f"每10天休息1天,365天后能力值是{ability:.4f}")
ability = 1 for day in range(1, 366): if day % 15 != 0: if (day - 1) % 7 < 3: ability = ability else: ability *= 1.01 else: ability = ability print(f"每15天休息1天,365天后能力值是{ability:.4f}")
3.4
num = input("請(qǐng)輸入一個(gè)5位數(shù)字: ") if num == num[::-1]: print(f"{num}是回文數(shù)") else: print(f"{num}不是回文數(shù)")
3.5
print("+-------+-------+") for _ in range(3): print("| | |") print("+-------+-------+") for _ in range(3): print("| | |") print("+-------+-------+")

浙公網(wǎng)安備 33010602011771號(hào)