저는 코딩의 초보자입니다. 파이썬을 사용하여 2 차 방정식 계산기를 만들려고합니다.if 문에서 부울 연산자 사용
while True:
print("""
Welcome to DJIGURDA Supreme Quadratic Calculator
Please enter three values in the form of /'ax^2 + bx +c/'. """)
a = input("a (first constant)")
b = input("b (second constant)")
c = input("c (third constant)")
if not a.isalpha and not b.isalpha and not c.isalpha:
d = (float(b)**2) - (4 * float(a) * float(c))
print(d)
if d >= 0:
x_1 = (float(-b) + (d**0.5))/(2*float(a))
x_2 = (float(-b) - (d**0.5))/(2*float(a))
print("The first variable is equal to %s./n The second variable is equal to %s")[str(x_1), str(x_2)]
else:
print("No real roots.")
else:
print("Please enter numerical values.")
이 코드는 "Please enter numerical values." 코드가 첫 번째 "if"문을 지나치지 않는 이유는 무엇입니까?
대괄호. 각 부울'if' 섹션에 주위에 대괄호'()'가 있어야합니다. – Tim
'(a.isalpha()가 아니라 if (b.isalpha()가 아님) 그리고 (c.isalpha()가 아님)' – Tim
'a.isalpha()'가 필요합니다. –