minute = int(input("Enter the number of minutes:"))
year = minute // (60 * 24 * 365)
day = minute % (60 * 24 * 365) // (60 * 24)
print(f"{minute} minutes is approximately {year} years and {day} days")
注释:
minute // (60 * 24 * 365):计算年数 用“//”取整运算
minute % (60 * 24 * 365):计算年数时取余的分钟数 进而计算剩余分钟的天数
结果演示:
Demo05
M = float(input("Enter the amount do water in kilograms:"))
initialTemperature = float(input("Enter the initial temperature:"))
finalTemperature = float(input("Enter the final temperature:"))
Q = M * (finalTemperature - initialTemperature) * 4184
print(f"The energy needed is {Q}")