From cadc7d2880b2ae5eeaa4efde9dd95c60acda2e5a Mon Sep 17 00:00:00 2001 From: Arjun Ravindra Date: Sat, 23 Aug 2025 17:29:25 +0530 Subject: [PATCH 1/3] Python calculator file --- My cal.py => MyCal.py | 196 +++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 98 deletions(-) rename My cal.py => MyCal.py (97%) diff --git a/My cal.py b/MyCal.py similarity index 97% rename from My cal.py rename to MyCal.py index d5be8a4..c209d9a 100644 --- a/My cal.py +++ b/MyCal.py @@ -1,98 +1,98 @@ -from tkinter import* - -me=Tk() -me.geometry("354x460") -me.title("CALCULATOR") -melabel = Label(me,text="CALCULATOR",bg='White',font=("Times",30,'bold')) -melabel.pack(side=TOP) -me.config(background='Dark gray') - -textin=StringVar() -operator="" - -def clickbut(number): #lambda:clickbut(1) - global operator - operator=operator+str(number) - textin.set(operator) - -def equlbut(): - global operator - add=str(eval(operator)) - textin.set(add) - operator='' -def equlbut(): - global operator - sub=str(eval(operator)) - textin.set(sub) - operator='' -def equlbut(): - global operator - mul=str(eval(operator)) - textin.set(mul) - operator='' -def equlbut(): - global operator - div=str(eval(operator)) - textin.set(div) - operator='' - -def clrbut(): - textin.set('') - - -metext=Entry(me,font=("Courier New",12,'bold'),textvar=textin,width=25,bd=5,bg='powder blue') -metext.pack() - -but1=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(1),text="1",font=("Courier New",16,'bold')) -but1.place(x=10,y=100) - -but2=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(2),text="2",font=("Courier New",16,'bold')) -but2.place(x=10,y=170) - -but3=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(3),text="3",font=("Courier New",16,'bold')) -but3.place(x=10,y=240) - -but4=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(4),text="4",font=("Courier New",16,'bold')) -but4.place(x=75,y=100) - -but5=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(5),text="5",font=("Courier New",16,'bold')) -but5.place(x=75,y=170) - -but6=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(6),text="6",font=("Courier New",16,'bold')) -but6.place(x=75,y=240) - -but7=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(7),text="7",font=("Courier New",16,'bold')) -but7.place(x=140,y=100) - -but8=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(8),text="8",font=("Courier New",16,'bold')) -but8.place(x=140,y=170) - -but9=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(9),text="9",font=("Courier New",16,'bold')) -but9.place(x=140,y=240) - -but0=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(0),text="0",font=("Courier New",16,'bold')) -but0.place(x=10,y=310) - -butdot=Button(me,padx=47,pady=14,bd=4,bg='white',command=lambda:clickbut("."),text=".",font=("Courier New",16,'bold')) -butdot.place(x=75,y=310) - -butpl=Button(me,padx=14,pady=14,bd=4,bg='white',text="+",command=lambda:clickbut("+"),font=("Courier New",16,'bold')) -butpl.place(x=205,y=100) - -butsub=Button(me,padx=14,pady=14,bd=4,bg='white',text="-",command=lambda:clickbut("-"),font=("Courier New",16,'bold')) -butsub.place(x=205,y=170) - -butml=Button(me,padx=14,pady=14,bd=4,bg='white',text="*",command=lambda:clickbut("*"),font=("Courier New",16,'bold')) -butml.place(x=205,y=240) - -butdiv=Button(me,padx=14,pady=14,bd=4,bg='white',text="/",command=lambda:clickbut("/"),font=("Courier New",16,'bold')) -butdiv.place(x=205,y=310) - -butclear=Button(me,padx=14,pady=119,bd=4,bg='white',text="CE",command=clrbut,font=("Courier New",16,'bold')) -butclear.place(x=270,y=100) - -butequal=Button(me,padx=151,pady=14,bd=4,bg='white',command=equlbut,text="=",font=("Courier New",16,'bold')) -butequal.place(x=10,y=380) -me.mainloop() - - +from tkinter import* + +me=Tk() +me.geometry("354x460") +me.title("CALCULATOR") +melabel = Label(me,text="CALCULATOR",bg='White',font=("Times",30,'bold')) +melabel.pack(side=TOP) +me.config(background='Dark gray') + +textin=StringVar() +operator="" + +def clickbut(number): #lambda:clickbut(1) + global operator + operator=operator+str(number) + textin.set(operator) + +def equlbut(): + global operator + add=str(eval(operator)) + textin.set(add) + operator='' +def equlbut(): + global operator + sub=str(eval(operator)) + textin.set(sub) + operator='' +def equlbut(): + global operator + mul=str(eval(operator)) + textin.set(mul) + operator='' +def equlbut(): + global operator + div=str(eval(operator)) + textin.set(div) + operator='' + +def clrbut(): + textin.set('') + + +metext=Entry(me,font=("Courier New",12,'bold'),textvar=textin,width=25,bd=5,bg='powder blue') +metext.pack() + +but1=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(1),text="1",font=("Courier New",16,'bold')) +but1.place(x=10,y=100) + +but2=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(2),text="2",font=("Courier New",16,'bold')) +but2.place(x=10,y=170) + +but3=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(3),text="3",font=("Courier New",16,'bold')) +but3.place(x=10,y=240) + +but4=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(4),text="4",font=("Courier New",16,'bold')) +but4.place(x=75,y=100) + +but5=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(5),text="5",font=("Courier New",16,'bold')) +but5.place(x=75,y=170) + +but6=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(6),text="6",font=("Courier New",16,'bold')) +but6.place(x=75,y=240) + +but7=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(7),text="7",font=("Courier New",16,'bold')) +but7.place(x=140,y=100) + +but8=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(8),text="8",font=("Courier New",16,'bold')) +but8.place(x=140,y=170) + +but9=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(9),text="9",font=("Courier New",16,'bold')) +but9.place(x=140,y=240) + +but0=Button(me,padx=14,pady=14,bd=4,bg='white',command=lambda:clickbut(0),text="0",font=("Courier New",16,'bold')) +but0.place(x=10,y=310) + +butdot=Button(me,padx=47,pady=14,bd=4,bg='white',command=lambda:clickbut("."),text=".",font=("Courier New",16,'bold')) +butdot.place(x=75,y=310) + +butpl=Button(me,padx=14,pady=14,bd=4,bg='white',text="+",command=lambda:clickbut("+"),font=("Courier New",16,'bold')) +butpl.place(x=205,y=100) + +butsub=Button(me,padx=14,pady=14,bd=4,bg='white',text="-",command=lambda:clickbut("-"),font=("Courier New",16,'bold')) +butsub.place(x=205,y=170) + +butml=Button(me,padx=14,pady=14,bd=4,bg='white',text="*",command=lambda:clickbut("*"),font=("Courier New",16,'bold')) +butml.place(x=205,y=240) + +butdiv=Button(me,padx=14,pady=14,bd=4,bg='white',text="/",command=lambda:clickbut("/"),font=("Courier New",16,'bold')) +butdiv.place(x=205,y=310) + +butclear=Button(me,padx=14,pady=119,bd=4,bg='white',text="CE",command=clrbut,font=("Courier New",16,'bold')) +butclear.place(x=270,y=100) + +butequal=Button(me,padx=151,pady=14,bd=4,bg='white',command=equlbut,text="=",font=("Courier New",16,'bold')) +butequal.place(x=10,y=380) +me.mainloop() + + From 41cd78d0f3bf02dda0a4aea5b3fddca074705361 Mon Sep 17 00:00:00 2001 From: Arjun Ravindra Date: Sat, 23 Aug 2025 19:45:03 +0530 Subject: [PATCH 2/3] Pentagon using turtle --- Pentagon.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Pentagon.py diff --git a/Pentagon.py b/Pentagon.py new file mode 100644 index 0000000..b742533 --- /dev/null +++ b/Pentagon.py @@ -0,0 +1,27 @@ +import turtle + +# Setup screen +screen = turtle.Screen() +screen.title("Pentagon with Turtle") +screen.bgcolor("lightyellow") + +# Create turtle +t = turtle.Turtle() +t.speed(5) +t.color("blue") +t.pensize(3) + +# Draw a pentagon +sides = 5 +length = 100 # length of each side +angle = 360 / sides # turn angle + +for _ in range(sides): + t.forward(length) + t.right(angle) + +# Hide turtle +t.hideturtle() + +# Keep window open +turtle.done() From d3ae0204f07deee2f5d9a5b94e3d7f29bc1a313c Mon Sep 17 00:00:00 2001 From: arjunravindraalur Date: Sat, 23 Aug 2025 20:14:36 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index da5b7e3..a29df5d 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Calculator-in-python3-tkinter \ No newline at end of file +# Calculator in python3 tkinter