from tkinter import * import random col=['pink','cyan','blue','navy','red','yellow','orange','grey','black','white','green'] r=Tk() Frame(r,width=1200,height=2000,bg=random.choice(col)).place(x=0,y=0) Frame(r,width=620,height=600,bg=random.choice(col)).place(x=50,y=470) e1=Entry(r,fg='black') e1.place(x=100,y=60,height=70,width=400) e2=Entry(r,fg='black') e2.place(x=100,y=160,height=70,width=400) def bu(tex,bb,ff,cc,xx,yy): Button(r,text=tex,bg=bb,fg=ff,bd=7,command=cc).place(x=int(xx)+20,y=int(yy)+100,width=110,height=110) def o(): O['text']='Enter valid number' def os(): O['text']='Enter valid numbers' def sum(): try: O['text']=float(e1.get())+float(e2.get()) except: os() bu('+','orange','black',sum,'60','400') def sub(): try: O['text']=float(e1.get())-float(e2.get()) except: os() bu('-','orange','black',sub,'210','400') def mul(): try: O['text']=float(e1.get())*float(e2.get()) except: os() bu('*','orange','black',mul,'360','400') def div(): try: O['text']=float(e1.get())/float(e2.get()) except: os() bu('/','orange','black',div,'510','400') def sq(): try: O['text']=float(e1.get())**2 except: o() bu('x²','orange','black',sq,'60','550') def sqrt(): try: O['text']=float(e1.get())**0.5 except: o() bu('√','orange','black',sqrt,'210','550') def pow(): try: O['text']=float(e1.get())**float(e2.get()) except: os() bu('x^a','orange','black',pow,'360','550') def powrt(): try: O['text']=float(e1.get())**(1/float(e2.get())) except: os() bu('x√','orange','black',powrt,'510','550') def dice(): O['text']=random.randint(1,6) bu('DICE','orange','black',dice,'60','700') def toss(): qq=random.randint(1,2) if qq==1: O['text']='HEADS' elif qq==2: O['text']='TAILS' bu('TOSS','orange','black',toss,'210','700') def rand(): try: O['text']=random.randint(int(e1.get()),int(e2.get())) except: O['text']='enter valid numbers (num1