# Python TQC考題108座標距離計算
x1=eval(input()) #2
y1=eval(input()) #1
x2=eval(input()) #5.5
y2=eval(input()) #8
dist=((x1-x2)**2+(y1-y2)**2)**0.5
import math #第二種作法
dist1=math.sqrt((x1-x2)**2+(y1-y2)**2)
# math.pow()可以做2次方,但**比較簡短
print(“( {:} , {:} )”.format(x1,y1))
print(“( {:} , {:} )”.format(x2,y2))
print(“Distance = {:.4f}”.format(dist))
print(dist1)
#第二種作法,只確認答案一樣,格式要再設定好


#tuple確實跟題目要的座標樣式很像
#可惜x1, x2的前後少了空白

#這一題基本上沒有難度
#就是考空白的位置是否正確



![Python Pathlib 實戰:優雅地篩選多種圖片檔案; images = [f for f in p.glob(“*”) if f.suffix.lower() in img_extensions] Python Pathlib 實戰:優雅地篩選多種圖片檔案; images = [f for f in p.glob(“*”) if f.suffix.lower() in img_extensions]](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2026/01/20260128111659_0_736612.png?quality=90&zoom=2&ssl=1&resize=350%2C233)







近期留言