HW02 運算子表達式
1. NotebookLM https://notebook.google.com/notebook/38bdd2a8-374e-457e-a72a-6c5175a61f1f 2. YouTube 3. 學習卡 4. 測驗 5. 寫1個程式需附加說明 Create a README For Github 115103104 % 7 + 1 = 5 1. GitHub 專案名稱 python-car-speed-calculator 專案功能:輸入汽車行駛的距離(公尺)與時間(秒),計算汽車的平均速度(公尺/秒)。 2. Python 程式碼: main.py # Python Car Speed Calculator # Calculate the speed of a car in meters per second. # Ask the user to enter the distance in meters distance = int ( input ( "Enter the distance in meters: " )) # Ask the user to enter the time in seconds time = int ( input ( "Enter time in seconds: " )) # Calculate the speed speed = distance / time # Display the result with two decimal places print ( "Speed of vehicle is %.2f" % speed , "meter/second" ) 程式碼說明 程式碼 功能 input() 讓使用者從鍵盤輸入資料 int() 將輸入的資料轉換成整數 distance 儲存行駛距離,單位是公尺 time 儲存行駛時間,單位是秒 speed = distance / time 計算平均速度 %.2f 將計算結果顯示到小數點後兩位 print() 在終端機顯示計算結果 公式: Speed = Distance Time \text{Speed}=\frac{\text{Distan...












留言
張貼留言