#Python TQC考題506 一元二次方程式
def compute(a,b,c):
cond=b**2-4*a*c
if cond >=0:
root1=(-b+cond**0.5)/(2*a)
root2=(-b-cond**0.5)/(2*a)
return root1,root2
else: return 0
a=eval(input())
b=eval(input())
c=eval(input())
if compute(a,b,c)==0:
print(“Your equation has no root.”)
else:
root1,root2=compute(a,b,c)
print(“{}, {}”.format(root1,root2))

# 第二次做
# 把print寫進去compute函數中
# return那裡改為print()
# 精簡了末段為print而做的if…else…
def compute(a,b,c):
cond=b**2-4*a*c
if cond >= 0:
root1=(-b+cond**0.5)/(2*a)
root2=(-b-cond**0.5)/(2*a)
print(root1,root2)
#其實少了題目要的逗點
else:print(“Your equation has no root.”)
a=eval(input())
b=eval(input())
c=eval(input())
compute(a,b,c)

#root1 , root2中間的逗點也是題目要的:

#題目沒說
#但是看輸出結果
#print()中要下格式 %.1f




![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)






近期留言