Python——一元多项式求导函数(采用公式法求导函数)(tkinter实现)
本功能作者:
1.CSDN用户(TDTX),TDTX主页
博客园用户(TDTX),TDTX主页
1.Derivativef.py
def Derivativef():
import tkinter as tk
linearwindow6=tk.Tk()
linearwindow6.title("Derivativef")
linearwindow6.geometry("600x700")
def derf():
yfs=[]
yfs=eval(e3.get())
lee=len(yfs)
# print(lee)
j=0
coo=0
i=0
for i in range(lee):
if yfs[i][1]!=0 and coo==0 and yfs[i][0]!=0:
tx.insert('insert',"dy/dx=\n({0}*x^{1})".format(yfs[i][0]*yfs[i][1],yfs[i][1]-1))
coo=coo+1
elif yfs[i][1]!=0 and yfs[i][0]!=0:
tx.insert('insert',"+({0}*x^{1})".format(yfs[i][0]*yfs[i][1],yfs[i][1]-1))
coo=coo+1
if coo==0:
tx.insert('insert',"0")
tx.insert('insert','\n\n')
lb1=tk.Label(linearwindow6, text='在[]从高到低输入系数和指数,\n以逗号分隔每一项,里examp:[[a5,5],[a3,3]]', bg='orange', font=('Arial', 12), width=37, height=2)
lb1.pack()
e3 = tk.Entry(linearwindow6,font=('Arial', 14),width=25)
e3.pack()
bt3=tk.Button(linearwindow6,text='生成导函数',width=17,height=2,font=('Arial', 12),command=derf)
bt3.pack()
tx=tk.Text(linearwindow6,width=39,height=30)
tx.pack()
linearwindow6.mainloop()
2.结果示例
【重新输入数据后,点击“生成导函数”按钮,会再换行输出结果!】