1 回答

TA貢獻1876條經驗 獲得超5個贊
我看到的問題是函數的輸入。您不需要 self 參數或任何其他參數。這些函數應該在循環之外運行。編輯后的版本應該像這樣循環:
class EquationSolver:
def MonomialSolver():
# Uses float() to turn input to a number
a = float(input("Enter Input for a:"))
b = float(input("Enter Input for b:"))
c = float(input("Enter input for c:"))
x = (c+b)/a
print("For the equation in the format ax-b=c, with your values chosen x must equal", x)
def PolynomialSolver():
a = float(input("Enter Input for a:"))
b = float(input("Enter Input for b:"))
c = float(input("Enter input for c:"))
x = (c^2 + b) / a
print("For the equation in the format sqrt(ax+b) = c, with your values chosen x must equal", x)
EquationSolver.MonomialSolver()
EquationSolver.PolynomialSolver()
添加回答
舉報