#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爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件) Python爬蟲:BeautifulSoup的 .find_all() 與 .find() 與 .select(‘標籤名[屬性名1=”屬性值1″][屬性名2=”屬性值2″]’) ; from bs4 import BeautifulSoup ; Live Server(可以預覽HTML的VS Code套件)](https://i2.wp.com/savingking.com.tw/wp-content/uploads/2025/03/20250330190318_0_925655.jpg?quality=90&zoom=2&ssl=1&resize=350%2C233)



近期留言