計算停車的時間(ai期末作業)

def calculate_parking_fee(parking_duration):
# 定義每小時停車費用和最高停車費用
hourly_rate = 50
minimum_fee = 25
max_fee = 1000

# 計算停車費用
if parking_duration < 1:
    parking_fee = minimum_fee
else:
    parking_fee = min(hourly_rate * parking_duration, max_fee)

return parking_fee

輸入停車時間(以小時為單位)

try:
parking_duration = float(input(“請輸入停車時間(小時):”))
if parking_duration < 0:
print(“停車時間不能為負數”)
else:
fee = calculate_parking_fee(parking_duration)
print(“停車費用為:{}元”.format(fee))

except ValueError:
print(“請輸入有效的數字”)

You will need to convert your title to English so that community members can help you.
Ok, tried google translate, and I got this:

Calculate parking time (ai final homework)

So, what is it that you would like help with?

1 Like

I can’t see how the code shown here could have anything to do with AI.

It is just some code without indent.
So, what is the problem? You can not run the program?