Python Can';我不能让代数(二次公式)起作用

Python Can';我不能让代数(二次公式)起作用,python,calculator,algebra,quadratic,Python,Calculator,Algebra,Quadratic,我一直在为一门计算机科学课程做一个非常简单的计算器,它有一些函数,计算器的函数是解二次方程。我已尝试使其工作,但出现以下错误:。我不明白为什么它会这样做,因为我输入了所有的内容。。如果有人能帮忙,那就太好了 import tkinter as tk import math from functools import partial #defining functions for operations #Addition def add_result(label_result, n1, n2):

我一直在为一门计算机科学课程做一个非常简单的计算器,它有一些函数,计算器的函数是解二次方程。我已尝试使其工作,但出现以下错误:。我不明白为什么它会这样做,因为我输入了所有的内容。。如果有人能帮忙,那就太好了

import tkinter as tk
import math
from functools import partial

#defining functions for operations
#Addition
def add_result(label_result, n1, n2):
    num1 = (n1.get())
    num2 = (n2.get())
    result = float(num1)+float(num2)
    label_result.config(text="Result is %d" % result)
    return

#Multiplication
def mult_result(label_result, n1, n2):
    num1 = (n1.get())
    num2 = (n2.get())
    result = float(num1)*float(num2)
    label_result.config(text="Result is %d" % result)
    return

#Subtraction
def sub_result(label_result, n1, n2):
    num1 = (n1.get())
    num2 = (n2.get())
    result = float(num1)-float(num2)
    label_result.config(text="Result is %d" % result)
    return

#Division
def div_result(label_result, n1, n2):
    num1 = (n1.get())
    num2 = (n2.get())
    result = float(num1)/float(num2)
    label_result.config(text="Result is %d" % result)
    return

#SquareRoot
def sqrt_result(label_result, n1):
    num1 = (n1.get())
    result = math.sqrt(float(num1))
    label_result.config(text="Result is %d" % result)
    return

def algebraMode(label_result, n1, n2, n3):
    num1 = (n1.get())
    num2 = (n2.get())
    num3 = (n3.get())
    sol1 = (-float(num2) + math.sqrt(float(num2)**2 - 4*float(num1)*float(num3))) / (2 * float(num1))
    sol2 = (-float(num2) - math.sqrt(float(num2)**2 - 4*float(num1)*float(num3))) / (2 * float(num1))
    label_result.config(text="The solutions are %d" % sol1 + " %d" % sol2)
    return



root = tk.Tk()
root.geometry('450x170+100+200')
root.title('Simple Calculator')

number1 = tk.StringVar()
number2 = tk.StringVar()
number3 = tk.StringVar()


labelNum1 = tk.Label(root, text="Enter a number").grid(row=2, column=1)
labelNum2 = tk.Label(root, text="Enter another number").grid(row=3, column=1)
labelNum3 = tk.Label(root, text="Enter another number (Algebra Mode Only)").grid(row=4, column=1)
labelResult = tk.Label(root)
labelResult.grid(row=7, column=2)

entryNum1 = tk.Entry(root, textvariable=number1).grid(row=2, column=2)
entryNum2 = tk.Entry(root, textvariable=number2).grid(row=3, column=2)
entryNum3 = tk.Entry(root, textvariable=number3).grid(row=4, column=2)
add_result = partial(add_result, labelResult, number1, number2)
mult_result = partial(mult_result, labelResult, number1, number2)
sub_result = partial(sub_result, labelResult, number1, number2)
div_result = partial(div_result, labelResult, number1, number2)
sqrt_result = partial(sqrt_result, labelResult, number1, number2)
buttonCal = tk.Button(root, text="Add", command=add_result).grid(row=1, column=0)
buttonCal = tk.Button(root, text="Multiply", comma=mult_result).grid(row=2, column=0)
buttonCal = tk.Button(root, text="Subtract", command=sub_result).grid(row=3, column=0)
buttonCal = tk.Button(root, text="Divide", command=div_result).grid(row=4, column=0)
buttonCal = tk.Button(root, text="Square Root", command=sqrt_result).grid(row=5, column=0)
buttonCal = tk.Button(root, text="Algebra", command=algebraMode).grid(row=6, column=0)
root.mainloop()

在下面添加以下代码
sqrt\u result=partial(..)


然后它应该像其他人一样工作。

发布代码,而不是屏幕截图。代码在那里,看起来您缺少部分定义:
algebraMode=partial(albegraMode,labelResult,number1,number2,number3)
谢谢您的回答。我觉得有点傻,因为我没有看到那个哈哈。
algebraMode = partial(algebraMode, labelResult, number1, number2, number3)