EX4 - ◯年は何秒? Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

説明ページに戻る

問題文

次のプログラムをコピー&ペーストして、指定した場所にプログラムを追記することで問題を解いて下さい。

seconds = 365 * 24 * 60 * 60
print()  # 1年は何秒か出力
print()  # 2年は何秒か出力
print()  # 5年は何秒か出力
print()  # 10年は何秒か出力

int型の変数secondsは一年の秒数を表しています。これを利用して

  • 1年は何秒か
  • 2年は何秒か
  • 5年は何秒か
  • 10年は何秒か

を順に一行ずつ表示するプログラムを作って下さい。
うるう秒やうるう年のことは考え無くて良いとします。

実行結果(一部を「?????」で隠しています)
31536000
63072000
?????
?????

解答例

必ず自分で問題に挑戦してみてから見てください。

クリックで解答例を見る
seconds = 365 * 24 * 60 * 60
print(seconds)  # 1年は何秒か出力
print(seconds * 2)  # 2年は何秒か出力
print(seconds * 5)  # 5年は何秒か出力
print(seconds * 10)  # 10年は何秒か出力