PW Akshay

Generation

fix invalid codeSun, 11 Dec 2022

from tkinter import * def result(a,b): print(a,b) return int(a) * int(b) def btnclick(i): operation = i if(operation == "add"): res = result(e1.get(),e2.get()) e3.delete(0,END) e3.insert(0,res) elif(operation == "sub"): res = result(e1.get(),e2.get()) e3.delete(0,END) e3.insert(0,res) elif(operation == "mul"): res = result(e1.get(),e2.get()) e3.delete(0,END) e3.insert(0,res) elif(operation == "div"): res = result(e1.get(),e2.get()) e3.delete(0,END) e3.insert(0,res) else: pass def btnclear(): e1.delete(0,END) e2.delete(0,END) e3.delete(0,END) root = Tk() root.configure(bg = "white") root.title("Calculator") root.geometry("400x500") e1 = Entry(root, font = "none 30", bg = "white",width = 30) e1.pack() e2 = Entry(root, font = "none 30", bg = "white",width = 30) e2.pack() e3 = Entry(root, font = "none 30", bg = "white",width = 30) e3.pack() B_ADD = Button(root, text = "ADD", font = "none 30",width = 10, command = lambda:btnclick("add")) B_ADD.pack() B_SUB = Button(root, text = "SUB", font = "none 30",width = 10, command = lambda:btnclick("sub")) B_SUB.pack() B_MUL = Button(root, text = "MUL", font = "none 30",width = 10, command = lambda:btnclick("mul")) B_MUL.pack() B_DIV = Button(root, text = "DIV", font = "none 30",width = 10, command = lambda:btnclick("div")) B_DIV.pack() B_EQ = Button(root, text = "EQ", font = "none 30",width = 10,command = lambda:btnclick("")) B_EQ.pack() B_CLEAR = Button(root, text = "CLEAR", font = "none 30",width = 10, command = btnclear) B_CLEAR.pack() root.mainloop() if __name__ == "__main__": main()

![calculator_output](https://user-images.githubusercontent.com/54179065/65385323-e6c8b800-ddb2-11e9-8f36-9af7a3c3e3f7.png) ## MACHINE LEARNING **1) K-NEAREST NEIGHBOURS(KNN)** * KNN is a supervised machine learning algorithm which can be used for both classification as well as regression problems. But it is mostly used in classification problems. * KNN is a non-parametric and lazy learning algorithm. Non-parametric means there is no assumption for underlying data distribution. In other words, the model structure determined from the dataset. This will be very helpful in practice where most of the real world datasets do not follow mathematical theoretical assumptions. Lazy algorithm means it does not need any training data points for model generation. All training data used in the testing phase. This makes training faster and testing phase slower and costlier. Costly testing phase means time and memory. * KNN algorithm uses ‘feature similarity’ to predict the

Questions about programming?Chat with your personal AI assistant