题目
(计算年数和天数)编写一个程序,提示用户输入分钟数(例如:1000000),然后将分钟转换为年数和天数并显示的程序。为了简单起见,假定一年有365天。这里是一个示例运行。
Enter the number of minutes:1000000000
Enter1000000000 minutes is approximately 1902 years and 214 days
分析
公式1:分钟 / 60 --> 时数 / 24 --> 天数 / 365 = 年数
公式2:分钟 / 60 --> 时数 / 24 --> 天数 % 365 =剩余天数
代码
m = float(input("请输入分钟数:"))
y = m // 60 // 24 // 365
d = m // 60 // 24 % 365
a = f"年数:{int(y)} 天数:{int(d)}"
print(a)