#Python TQC考題602 撲克牌總和
sum = 0
for i in range(5):
s=input()
“””
# 使用者可能輸入數字或文字
#都先當成文字,
# 若是數字,在else那一行,
# 用int 或eval轉為數字
“””
if s == “J” or s == “j”:
sum=sum+11
elif s==”Q” or s==”q”:
sum=sum+12
elif s==”K” or s==”k”:
sum=sum+13
elif s==”A” or s==”a”:
sum=sum+1
else: sum=sum+int(s)
print(sum)

#原本的寫法比較簡單,
#只是沒有使用者輸入超出範圍的防呆
#第二次寫:
sum=0
L=[“2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”10”]
#因為可能輸入數字或字串
#先預設輸入字串,
#若為數字,再用eval轉回數字
for i in range(5):
n=input()
if n in L: sum=sum+eval(n)
elif n == “A” or “a”: sum=sum+1
elif n == “J” or “j”: sum=sum+11
elif n == “Q” or “q”: sum=sum+12
elif n == “K” or “k”: sum=sum+13
else:print(“請輸入正確的範圍”)
print(sum)

#再練習一次:






![Python: 如何使用 pydub (dub:配音)將m4a 轉換為wav? 用 os.environ [ “PATH” ] 設定環境變量; from pydub import AudioSegment Python: 如何使用 pydub (dub:配音)將m4a 轉換為wav? 用 os.environ [ “PATH” ] 設定環境變量; from pydub import AudioSegment](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2024/09/20240905141103_0_95957e.png?quality=90&zoom=2&ssl=1&resize=350%2C233)

![Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content Python如何串接OpenAI /Claude /Gemini API自動將大量維修紀錄JSON轉自然語言描述(並避免中斷資料遺失)response = client.chat.completions.create() ; reply = response.choices[0].message.content](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/07/20250716084059_0_c5b368.png?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言