"""第 03 章 運算、字串與輸入輸出。"""

# arithmetic
print(2 + 3 * 4, (2 + 3) * 4)
print(125 / 60 > 2)
print(125 // 60, 125 % 60)

# time-label
label = "  通話  ".strip()
minutes = 2
seconds = 5
print(f"{label} {minutes}:{seconds:02d}")

# input-duration
use_interactive_input = False  # @param {type:"boolean"}
raw_seconds = input("請輸入非負整數秒數：") if use_interactive_input else "125"
try:
    total_seconds = int(raw_seconds)
except ValueError:
    print("請輸入整數秒數。")
else:
    if total_seconds < 0:
        print("秒數不可小於 0。")
    else:
        minutes = total_seconds // 60
        seconds = total_seconds % 60
        print(f"{minutes} 分 {seconds} 秒")

# duration-practice
total_seconds = 3661
raw_duration = " 75 "
# 在這裡完成兩種換算。
print("整理輸入後再進行時間換算。")

# duration-solutions
total_seconds = 3661
hours = total_seconds // 3600
remaining_seconds = total_seconds % 3600
print(f"{hours} 小時 {remaining_seconds // 60} 分 {remaining_seconds % 60} 秒")

seconds = int(" 75 ".strip())
print(f"時長 {seconds // 60}:{seconds % 60:02d}")
