Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf8 -*-
- from math import *
- from string import *
- def destroy(event):
- root.destroy()
- def menu1(event):
- window = Toplevel(bg='#a3a8a5')
- window.geometry("200x260+460+100")
- window.maxsize(width=200, height=260)
- window.minsize(width=200, height=260)
- window.title('')
- framee = Frame(window, width=200, height=46, bg='#575b59')
- framee2 = Frame(window, bg='black')
- framee3 = Frame(window, bg='black')
- biton = Button(framee2, text='Интегрирование', font='20', width=12, padx=25, pady=20, bg='#e1f4e8',
- activebackground='#4df98c', fg='black')
- biton2 = Button(framee3, text='Дифференцирование', font='20', width=12, padx=25, pady=20, bg='#e1f4e8',
- activebackground='#4df98c', fg='black')
- framee.pack()
- framee2.pack(pady=20)
- framee3.pack()
- biton.pack(padx=2, pady=2)
- biton2.pack(padx=2, pady=2)
- biton.bind('<Button-1>', first1)
- biton2.bind('<Button-1>', first2)
- def menu2(event):
- window = Toplevel(bg='#a3a8a5')
- window.geometry("300x280+460+100")
- window.maxsize(width=300, height=300)
- window.minsize(width=300, height=300)
- window.title('')
- framee = Frame(window, width=300, height=46, bg='#575b59')
- framee2 = Frame(window, bg='black')
- framee3 = Frame(window, bg='black')
- biton = Button(framee2, text='Решение \nнелинейных уравнений', font='Calibri 11', width=18, height=2, padx=25,
- pady=20, bg='#dee6f7', activebackground='#548aff', fg='black')
- biton2 = Button(framee3, text='Решение дифференциальных \nуравнений', font='Calibri 11', width=18, height=2,
- padx=25, pady=20, bg='#dee6f7', activebackground='#548aff', fg='black')
- framee.pack()
- framee2.pack(pady=20)
- framee3.pack()
- biton.pack(padx=2, pady=2)
- biton2.pack(padx=2, pady=2)
- biton.bind('<Button-1>', second1)
- biton2.bind('<Button-1>', second2)
- def first1(event):
- def raschet(event):
- try:
- funciya = ent22.get()
- x = float(ent32.get())
- b = float(ent34.get())
- n = float(ent24.get())
- if b <= x:
- text51.delete(1.0, END)
- text51.insert(1.0, 'Отрезок задан неправильно.')
- elif n <= 0 or n % 1 != 0:
- text51.delete(1.0, END)
- text51.insert(1.0, 'Количество фигур задано неправильно.')
- else:
- text51.delete(1.0, END)
- n = int(ent24.get())
- step = (b - x) / n
- S = 0
- GG = 0
- A = x
- while GG != n:
- x = x + step
- S = S + eval(funciya) * step
- GG += 1
- S = round(S, 12)
- text51.insert(1.0, 'Метод левых прямоугольников:' + 16 * ' ' + str(S) + '\n')
- x = A
- GG = 0
- S = 0
- while GG != n:
- S = S + eval(funciya) * step
- x = x + step
- GG += 1
- S = round(S, 12)
- text51.insert(1.0, 'Метод правых прямоугольников:' + 14 * ' ' + str(S) + '\n')
- x = A
- GG = 0
- S = 0
- while GG != n:
- x = x + (step / 2)
- S = S + eval(funciya) * step
- x = x + (step / 2)
- GG += 1
- S = round(S, 12)
- text51.insert(1.0, 'Метод серединных прямоугольников:' + 6 * ' ' + str(S) + '\n')
- x = A
- GG = 0
- S = 0
- while GG != n:
- S = S + (0.5 * step * (eval(funciya)))
- x = x + step
- S = S + (0.5 * step * (eval(funciya)))
- GG += 1
- S = round(S, 12)
- text51.insert(1.0, 'Метод трапеций: ' + 43 * ' ' + str(S) + '\n')
- x = A
- n = int(ent24.get())
- X = list()
- Y = list()
- step = float(b - x) / (2 * n)
- S1 = 0
- S2 = 0
- for i in range(2 * n + 1):
- X.append(x)
- Y.append(eval(funciya))
- x += step
- for i in range(1, n + 1):
- S1 += Y[2 * i - 1]
- for i in range(1, n):
- S2 += Y[2 * i]
- answ = (step / 3) * (Y[0] + (4 * S1) + (2 * S2) + Y[2 * n])
- text51.insert(1.0, 'Методом парабол: ' + 39 * ' ' + str(round(answ, 12)) + '\n')
- except:
- text51.delete(1.0, END)
- text51.insert(1.0, 'Вы неправильно ввели функцию.')
- win1 = Toplevel(bg='#a3a8a5')
- win1.geometry("700x400+660+100")
- win1.minsize(width=600, height=400)
- win1.maxsize(width=600, height=800)
- win1.title('Интегрирование')
- frame1 = Frame(win1, bg='#a3a8a5', width=200)
- framesverhu = Frame(win1, bg='#575b59', width=700, height=46)
- frame2 = Frame(win1, bg='#a3a8a5', width=200)
- Lab11 = Label(frame1, text='Введите функцию: ', bg='#a3a8a5', fg='black', font='Calibri 18')
- Lab21 = Label(frame2, text='y =', font='Calibri 16', bg='#a3a8a5')
- ent22 = Entry(frame2, width=20)
- but23 = Button(frame2, text='CALCULATE', bg='#e1f4e8', activebackground='#4df98c', fg='black', bd=3)
- frame3 = Frame(win1, bg='#a3a8a5', width=200)
- Lab23 = Label(frame3, text='n =', font='Calibri 16', bg='#a3a8a5')
- ent24 = Entry(frame3, width=20)
- Lab31 = Label(frame3, text='a=', bg='#a3a8a5', font='Calibri 16')
- ent32 = Entry(frame3, width=5)
- Lab33 = Label(frame3, text='b=', bg='#a3a8a5', font='Calibri 16')
- ent34 = Entry(frame3, width=5)
- frame4 = Frame(win1, bg='#a3a8a5')
- Lab41 = Label(frame4, text='Поле вывода:', bg='#a3a8a5', fg='white', font='Calibri 11')
- text51 = Text(frame4, height=7, width=100, font='Arial 12', wrap=WORD, bd=3)
- ent22.insert(1, '(e**(sin(x)+2))*cos(x)')
- ent32.insert(1, '0')
- ent34.insert(1, '5')
- ent24.insert(1, '100')
- framesverhu.pack()
- frame1.pack()
- frame2.pack()
- frame3.pack()
- frame4.pack()
- Lab11.pack(side='left', padx=50)
- Lab21.pack(side='left')
- ent22.pack(side='left')
- but23.pack(side='left', padx=5)
- Lab31.pack(side='left')
- ent32.pack(side='left')
- Lab33.pack(side='left')
- ent34.pack(side='left')
- Lab23.pack(side='left')
- ent24.pack(side='left')
- Lab41.pack()
- text51.pack(side='left')
- but23.bind('<Button-1>', raschet)
- def first2(event):
- def calculate(event):
- try:
- Func = ent22.get()
- x = ent32.get()
- x = eval(x)
- dx = 0.00000001
- pervi = float(eval(Func))
- x = x + dx
- vtoroi = float(eval(Func))
- vivod = round((vtoroi - pervi) / dx, 8)
- ent51.delete(0, END)
- ent51.insert(1, vivod)
- except:
- ent51.delete(0, END)
- ent51.insert(1, 'Функция в данной точке не существует.')
- win1 = Toplevel(bg='#a3a8a5')
- win1.geometry("700x400+660+100")
- win1.minsize(width=600, height=400)
- win1.maxsize(width=600, height=400)
- win1.title('Дифференцирование')
- framehigh = Frame(win1, bg='#575b59', width=700, height=46)
- frame1 = Frame(win1, bg='#a3a8a5', width=200)
- frame2 = Frame(win1, bg='#a3a8a5', width=200)
- Lab11 = Label(frame1, text='Введите функцию: ', bg='#a3a8a5', fg='black', font='Calibri 18')
- Lab21 = Label(frame2, text='y =', font='Calibri 16', bg='#a3a8a5')
- ent22 = Entry(frame2, width=20)
- but23 = Button(frame2, text='CALCULATE', bg='#e1f4e8', activebackground='#4df98c', bd=3)
- frame3 = Frame(win1, bg='#a3a8a5', width=200)
- Lab31 = Label(frame3, text='x=', bg='#a3a8a5', font='Calibri 16')
- ent32 = Entry(frame3, width=5)
- frame4 = Frame(win1, bg='#a3a8a5')
- Lab41 = Label(frame4, text='Поле вывода:', bg='#a3a8a5', fg='white', font='Calibri 11')
- ent51 = Entry(frame4, width=100, font='Arial 12', bd=2)
- ent22.insert(1, '(e**x)/cos(x)')
- ent32.insert(1, '0')
- framehigh.pack()
- frame1.pack()
- frame2.pack()
- frame3.pack()
- frame4.pack()
- Lab11.pack(side='left', padx=50)
- Lab21.pack(side='left')
- ent22.pack(side='left')
- but23.pack(side='left', padx=5)
- Lab31.pack(side='left')
- ent32.pack(side='left')
- Lab41.pack()
- ent51.pack(side='left')
- but23.bind('<Button-1>', calculate)
- def second1(event):
- def non_linear_equations(event):
- text51.delete('1.0', END)
- function21 = ent22.get()
- from_a = float(ent32.get())
- to_b = float(ent34.get())
- num = float(ent35.get())
- precision = int(ent36.get())
- step21 = ((to_b-from_a)/num)
- x = from_a
- y = eval(function21)
- y_old = y
- roots = []
- while x < to_b:
- try:
- y = eval(function21)
- except ZeroDivisionError:
- y = y
- if y_old*y < 0 or y == 0:
- roots.append(x)
- x += step21
- y_old = y
- if roots:
- text51.insert(END, 'Корней уравнения: ' + str(len(roots)) + '\n')
- text51.insert(END, 'Корни: ' + '\n')
- for xx in roots:
- text51.insert(END, str(round(xx, precision)) + '\n')
- else:
- text51.insert(1.0, 'Уравнение не имеет корней на данном отрезке')
- win1 = Toplevel(bg='#a3a8a5')
- win1.geometry("700x600+760+100")
- win1.minsize(width=700, height=600)
- win1.maxsize(width=700, height=600)
- win1.title('Решение нелинейных уравнений')
- canvas = Canvas(win1, width=670, height=380, bg='white')
- framehigh = Frame(win1, bg='#575b59', width=700, height=46)
- frame1 = Frame(win1, bg='#a3a8a5', width=200)
- frame2 = Frame(win1, bg='#a3a8a5', width=200)
- Lab11 = Label(frame1, text='Введите функцию: ', bg='#a3a8a5', fg='black', font='Calibri 18')
- Lab21 = Label(frame2, text='y =', font='Calibri 16', bg='#a3a8a5')
- ent22 = Entry(frame2, width=20)
- but23 = Button(frame2, text='CALCULATE', bg='#dee6f7', activebackground='#548aff', bd=3)
- frame3 = Frame(win1, bg='#a3a8a5', width=200)
- Lab31 = Label(frame3, text='a=', bg='#a3a8a5', font='Calibri 16')
- ent32 = Entry(frame3, width=5)
- Lab33 = Label(frame3, text='b=', bg='#a3a8a5', font='Calibri 16')
- ent34 = Entry(frame3, width=5)
- Lab34 = Label(frame3, text='n=', bg='#a3a8a5', font='Calibri 16')
- ent35 = Entry(frame3, width=7)
- frame6 = Frame(win1, bg='#a3a8a5', width=200)
- Lab35 = Label(frame6, text='Знаков после запятой: ', bg='#a3a8a5', font='Calibri 16')
- ent36 = Entry(frame6, width=5)
- frame4 = Frame(win1, bg='#a3a8a5')
- Lab41 = Label(frame4, text='Ответ:', bg='#a3a8a5', fg='white', font='Calibri 11')
- frame5 = Frame(win1, bg='#a3a8a5')
- scroll = Scrollbar(frame5)
- scroll.pack(side=RIGHT, fill=Y, pady=10)
- text51 = Text(frame5, font='Calibri 11', wrap=WORD, bd=3, yscrollcommand=scroll.set)
- ent22.insert(1, 'cos(x)-sin(1/x)')
- ent32.insert(1, '-50')
- ent34.insert(1, '50')
- ent35.insert(1, '20000')
- ent36.insert(1, '8')
- framehigh.pack()
- frame1.pack()
- frame2.pack()
- frame3.pack()
- frame6.pack()
- frame4.pack()
- frame5.pack()
- canvas.pack(side='top', pady=15)
- Lab11.pack(side='left', padx=50)
- Lab21.pack(side='left')
- ent22.pack(side='left')
- but23.pack(side='left', padx=5)
- Lab31.pack(side='left')
- ent32.pack(side='left')
- Lab33.pack(side='left')
- ent34.pack(side='left')
- Lab34.pack(side='left')
- ent35.pack(side='left')
- Lab35.pack(side='left')
- ent36.pack(side='left')
- Lab41.pack(side='top')
- text51.pack(side='left', pady=10)
- scroll.config(command=text51.yview)
- but23.bind('<Button-1>', non_linear_equations)
- def second2(event):
- def diff_equations(event):
- x = 1
- win1 = Toplevel(bg='#a3a8a5')
- win1.geometry("700x600+760+100")
- win1.minsize(width=700, height=600)
- win1.maxsize(width=700, height=600)
- win1.title('Решение дифференциальных уравнений')
- canvas = Canvas(win1, width=670, height=380, bg='white')
- framehigh = Frame(win1, bg='#575b59', width=700, height=46)
- frame1 = Frame(win1, bg='#a3a8a5', width=200)
- frame2 = Frame(win1, bg='#a3a8a5', width=200)
- Lab11 = Label(frame1, text='Введите функцию: ', bg='#a3a8a5', fg='black', font='Calibri 18')
- Lab21 = Label(frame2, text="y'=", font='Calibri 16', bg='#a3a8a5')
- ent22 = Entry(frame2, width=20)
- but23 = Button(frame2, text='CALCULATE', bg='#dee6f7', activebackground='#548aff', bd=3)
- frame3 = Frame(win1, bg='#a3a8a5', width=200)
- Lab31 = Label(frame3, text='a=', bg='#a3a8a5', font='Calibri 16')
- ent32 = Entry(frame3, width=5)
- Lab33 = Label(frame3, text='b=', bg='#a3a8a5', font='Calibri 16')
- ent34 = Entry(frame3, width=5)
- frame4 = Frame(win1, bg='#a3a8a5')
- Lab41 = Label(frame4, text='Ответ:', bg='#a3a8a5', fg='white', font='Calibri 11')
- ent51 = Entry(frame4, width=100, font='Arial 12', bd=2)
- ent22.insert(1, '(y+x)/(y-x)')
- ent32.insert(1, '-50')
- ent34.insert(1, '50')
- framehigh.pack()
- frame1.pack()
- frame2.pack()
- frame3.pack()
- frame4.pack()
- canvas.pack(side='top', pady=15)
- Lab11.pack(side='left', padx=50)
- Lab21.pack(side='left')
- ent22.pack(side='left')
- but23.pack(side='left', padx=5)
- Lab31.pack(side='left')
- ent32.pack(side='left')
- Lab33.pack(side='left')
- ent34.pack(side='left')
- Lab41.pack(side='top')
- ent51.pack(side='top')
- but23.bind('<Button-1>', diff_equations)
- from Tkinter import *
- root = Tk()
- root.geometry("360x564+100+100")
- root.minsize(width=360, height=564)
- root.maxsize(width=360, height=564)
- root.title('Курсовая программа')
- fra1 = Frame(root, width=233 * 2, heigh=46, bg="#575b59")
- fra2 = Frame(root, heigh=560, bg="#a3a8a5")
- fra3 = Frame(root, bg="#494c4a")
- fra4 = Frame(fra3, bg="black")
- frab1 = Frame(fra2, bg='black')
- frab2 = Frame(fra2, bg='black')
- frab3 = Frame(fra2, bg='black')
- frab4 = Frame(fra2, bg='black', width=500)
- but1 = Button(frab1, text='Задача 1', font='20', width=12, padx=40, pady=20, bg='#e1f4e8', activebackground='#4df98c',
- fg='black')
- but2 = Button(frab2, text='Задача 2', font='20', width=12, padx=40, pady=20, bg='#dee6f7', activebackground='#548aff',
- fg='black')
- but3 = Button(frab3, text='Задача 3', font='20', width=12, padx=40, pady=20, bg='#f1def7', activebackground='#e07fff',
- fg='black')
- but4 = Button(frab4, text='Задача 4', font='20', width=12, padx=40, pady=20, bg='#f7e9de', activebackground='#ffa763',
- fg='black')
- but5 = Button(fra4, text='Выход', font='20', width=6, padx=21, pady=0, bg='#c64141', fg='white')
- but1.bind("<Button-1>", menu1)
- but2.bind("<Button-1>", menu2)
- but3.bind("<Button-1>", )
- but4.bind("<Button-1>", )
- but5.bind("<Button-1>", destroy)
- fra1.pack()
- fra2.pack()
- fra3.pack()
- fra4.pack(pady=15, padx=128)
- frab1.pack(pady=20, padx=80)
- frab2.pack(pady=20, padx=80)
- frab3.pack(pady=20, padx=80)
- frab4.pack(pady=20, padx=80)
- but1.pack(pady=2, padx=2)
- but2.pack(pady=2, padx=2)
- but3.pack(pady=2, padx=2)
- but4.pack(pady=2, padx=2)
- but5.pack(padx=1, pady=1)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement