Using the calculator program that you designed previously, add the functionality for the following buttons: C will clear the label. will add sqrt( to the label. x^y will add ^ to the label. % will add % to the label. LOG will add log( to the label. Will add value 3.14159... to the label. = will evaluate the expression. User will be notified of any syntax or division by 0 error. Note: For square root symbol, copy √ and paste it in the text of the button. For Π symbol, use text=u"\u220f" in the definition of the button. The code I want to add the functions in: from tkinter import * window=Tk() window.title("Calculator") lbl1=Label(text="",width=15,bg="#40E0D0") lbl1.place(x=0,y=10) window.resizable(False,False) btn1=Button(text=" C ") btn1.place(x=0,y=40) btn2=Button(text=" √ ") btn2.place(x=35,y=40) btn3=Button(text="x^y") btn3.place(x=72,y=40) btn4=Button(text=" % ") btn4.place(x=115,y=40) btn5=Button(text=" 1 ") btn5.place(x=0,y=85) btn6=Button(text=" 2 ") btn6.place(x=35,y=85) btn7=Button(text=" 3 ") btn7.place(x=72,y=85) btn8=Button(text=" + ") btn8.place(x=115,y=85) btn9=Button(text=" 4 ") btn9.place(x=0,y=130) btn10=Button(text=" 5 ") btn10.place(x=35,y=130) btn11=Button(text=" 6 ") btn11.place(x=72,y=130) btn12=Button(text=" - ") btn12.place(x=115,y=130) btn13=Button(text=" 7 ") btn13.place(x=0,y=175) btn14=Button(text=" 8 ") btn14.place(x=35,y=175) btn15=Button(text=" 9 ") btn15.place(x=72,y=175) btn16=Button(text=" * ") btn16.place(x=115,y=175) btn17=Button(text=" 0 ") btn17.place(x=0,y=220) btn18=Button(text=" . ") btn18.place(x=35,y=220) btn19=Button(text="LOG") btn19.place(x=72,y=220) btn20=Button(text=" / ") btn20.place(x=121,y=220) btn21=Button(text=" ( ") btn21.place(x=0,y=265) btn22=Button(text=" ) ") btn22.place(x=35,y=265) btn23=Button(text=u" \u220f ") btn23.place(x=72,y=265) btn24=Button(text=" = ") btn24.place(x=117,y=265) window.geometry("155x310") window.mainloop()
Using the calculator program that you designed previously, add the functionality for the following buttons:
C will clear the label.
will add sqrt( to the label.
x^y will add ^ to the label.
% will add % to the label.
LOG will add log( to the label.
Will add value 3.14159... to the label.
= will evaluate the expression. User will be notified of any syntax or division by 0 error.
Note: For square root symbol, copy √ and paste it in the text of the button.
For Π symbol, use text=u"\u220f" in the definition of the button.
The code I want to add the functions in:
from tkinter import *
window=Tk()
window.title("Calculator")
lbl1=Label(text="",width=15,bg="#40E0D0")
lbl1.place(x=0,y=10)
window.resizable(False,False)
btn1=Button(text=" C ")
btn1.place(x=0,y=40)
btn2=Button(text=" √ ")
btn2.place(x=35,y=40)
btn3=Button(text="x^y")
btn3.place(x=72,y=40)
btn4=Button(text=" % ")
btn4.place(x=115,y=40)
btn5=Button(text=" 1 ")
btn5.place(x=0,y=85)
btn6=Button(text=" 2 ")
btn6.place(x=35,y=85)
btn7=Button(text=" 3 ")
btn7.place(x=72,y=85)
btn8=Button(text=" + ")
btn8.place(x=115,y=85)
btn9=Button(text=" 4 ")
btn9.place(x=0,y=130)
btn10=Button(text=" 5 ")
btn10.place(x=35,y=130)
btn11=Button(text=" 6 ")
btn11.place(x=72,y=130)
btn12=Button(text=" - ")
btn12.place(x=115,y=130)
btn13=Button(text=" 7 ")
btn13.place(x=0,y=175)
btn14=Button(text=" 8 ")
btn14.place(x=35,y=175)
btn15=Button(text=" 9 ")
btn15.place(x=72,y=175)
btn16=Button(text=" * ")
btn16.place(x=115,y=175)
btn17=Button(text=" 0 ")
btn17.place(x=0,y=220)
btn18=Button(text=" . ")
btn18.place(x=35,y=220)
btn19=Button(text="LOG")
btn19.place(x=72,y=220)
btn20=Button(text=" / ")
btn20.place(x=121,y=220)
btn21=Button(text=" ( ")
btn21.place(x=0,y=265)
btn22=Button(text=" ) ")
btn22.place(x=35,y=265)
btn23=Button(text=u" \u220f ")
btn23.place(x=72,y=265)
btn24=Button(text=" = ")
btn24.place(x=117,y=265)
window.geometry("155x310")
window.mainloop()
Step by step
Solved in 2 steps with 1 images