#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: 如何使用pandas.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料 Python: 如何使用pandas.to_numeric ( df[‘numbers’], errors=’coerce’) 將非數值型資料轉為NaN? df[‘numbers’].describe() 簡述統計資料](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2024/05/20240501052102_0.png?quality=90&zoom=2&ssl=1&resize=350%2C233)
![Python: 使用 flat_list.extend( List[pandas.Series] ) 實現 pandas.DataFrame 列擴展教學 Python: 使用 flat_list.extend( List[pandas.Series] ) 實現 pandas.DataFrame 列擴展教學](https://i1.wp.com/savingking.com.tw/wp-content/uploads/2025/04/20250421141348_0_14cedf.png?quality=90&zoom=2&ssl=1&resize=350%2C233)







近期留言