SlideShare a Scribd company logo
1 of 6
Download to read offline
#package and module
#Module.py
person = {
"name":"john",
"age":34,
"country":"norway"
}
#file1.py
import Module
a = Module.person["name"]
print(a)
#class object and inheritance
class animal:
def speak(self):
print("animal is speaking")
class dog(animal):
def bark(self):
print("dog is barking")
d = dog()
d.bark()
d.speak()
#button widget
from tkinter import *
jayesh = Tk()
jayesh.geometry("300x500")
def akshay():
print("your button is clicked")
B = Button(jayesh,text="hello",command=akshay)
B.place(x=50,y=50)
jayesh.mainloop()
#string joining
def ask(list_string):
string="-".join(list_string)
return string
str1='vishal patil'
list_string=ask(str1)
print(list_string)
#OR
def ask(list_string):
string="-".join(list_string)
return string
str1=["vishal","patil"]
list_string=ask(str1)
print(list_string)
#arithmatic operators
num1 =int(input("enter the first no:"))
num2 =int(input("enter the second no:"))
add = num1+num2
sub = num1-num2
div = num1/num2
mul = num1*num2
print(add)
print(sub)
print(div)
print(mul)
#Tuple
my_tuple = ()
print(my_tuple)
# Tuple having integers
my_tuple = (1, 2, 3)
print(my_tuple)
# tuple with mixed datatypes
my_tuple = (1, "Hello", 3.4)
print(my_tuple)
# nested tuple
my_tuple = ("mouse", [8, 4, 6], (1, 2, 3))
print(my_tuple)
#novision looping statement
#for loop
for i in range(0,5):
print(i)
#while loop
count=0
while count<5:
print(count)
count=count+1
#nested for loop
for i in range(1, 7):
for j in range(i):
print(i, end=' ')
print()
#function
#simple function
def newl():
print("hello my name is akshay")
d=newl()
#function with parameters
def newl2(shila):
return shila*2
jawani=newl2(7)
print(jawani)
#function with parameters which having default value
def newl2(shila=14):
return shila*2
jawani=newl2()
print(jawani)
#funiction in a function
def outerFunction(text):
def innerFunction():
print(text)
innerFunction()
outerFunction("hey!")
#simple class and objects
class Animal:
def dog(self):
print("dog is barking")
d=Animal()
d.dog()
#list
list1=[1,2,3,4,5,6,8]
print(list1)
type(list1)#min,len,sum,type
#dictionaries
dict={}
dict[0]="hiii"
dict[10]="bye"
tinydict={"name":"akshay","age":23}
print(dict)
print(dict[0])
print(dict[10])
print(tinydict)
print(tinydict["name"])
print(tinydict["age"])
#range function
x = range(3, 20, 2)
for n in x:
print(n)
#len function
a=len("python")
print(a)
#lambda function
x=lambda x:x*2
a=x(7)
print(a)
#max function
max(1,2,3,4,5,7,5,10)
#min function
min(1,2,3,4,5,7,5,10)
#sum function
sum([1,2,3,4,5,6])
#config and resize
from tkinter import *
m =Tk()
m.geometry("400x300")
def on_button_click():
label.config(text="Hello, " + entry.get())
# Create the main window
m.title("GUI Example")
#m.minsize(200,100)
# Create a Label widget
label = Label(m, text="Welcome to Tkinter!")
label.pack(pady=10)
# Create an Entry widget
entry = Entry(m, width=30)
entry.pack(pady=10)
# Create a Button widget
button = Button(m, text="Click Me", command=on_button_click)
button.pack(pady=10)
# Configure options for resizing
m.resizable(True,True)#0,0
# Set the initial size of the window
# Run the main loop
m.mainloop()
#filter function
def maxi(x):
return x>4
l1=[2,3,4,5,6,7,8]
newl=list(filter(maxi,l1))
print(newl)
l1=[11,2,23,44,3,45]
print(l1)
#button widget
from tkinter import *
akshay=Tk()
akshay.geometry("300x500")
def file():
print("hello my name is akshay")
B=Button(akshay,text="submit",command=file)
B.place(x=50,y=50)
akshay.mainloop()
#entry widget
from tkinter import *
mayur=Tk()
mayur.geometry("500x400")
l1=Label(mayur,text="this is new program")
l1.pack(side=LEFT)
e1=Entry(mayur,bd=3)
e1.pack(side=LEFT)
mayur.mainloop()
#frame widget
from tkinter import *
mayur=Tk()
mayur.geometry("500x400")
frame=Frame(mayur)
frame.pack(side=BOTTOM)
Blue=Button(frame,text="hello",fg="white",bg="blue")
Blue.pack(side=LEFT)
Green=Button(frame,text="hello",fg="white",bg="green")
Green.pack(side=LEFT)
Red=Button(frame,text="hello",fg="white",bg="red")
Red.pack(side=LEFT)
yellow=Button(frame,text="hello",fg="white",bg="yellow")
yellow.pack(side=LEFT)
mayur.mainloop()
#checkbutton widget
from tkinter import *
drive=Tk()
drive.geometry("400x300")
checkvar1=IntVar()
checkvar2=IntVar()
ch1=Checkbutton(drive,text="pizza",variable=checkvar1,height=5,width=5)
ch2=Checkbutton(drive,text="fries",variable=checkvar2,height=5,width=5)
ch1.pack()
ch2.pack()
drive.mainloop()
#canvas widget
from tkinter import *
flight=Tk()
flight.geometry("400x300")
C=Canvas(flight,bg="cyan",height=100,width=100)
coord=10,50,90,70
arc=C.create_arc(coord,start=0,extent=97,fill="black")
line=C.create_line(10,10,50,70,fill="white")
C.pack()
flight.mainloop()
#list widget
from tkinter import *
listy=Tk()
#listy.geometry("400x500")
lb1=Listbox(listy)
lb1.insert(1,"hindi")
lb1.insert(2,"english")
lb1.insert(3,"marathi")
lb1.insert(4,"germany")
lb1.pack()
listy.mainloop()
#armstrong number
num=int(input("enter the number:"))
temp=num
sum=0
while temp>1:
digit=temp%10
sum+=digit**3
temp//=10
if num==sum:
print("armstrong")
else:
print("not")

More Related Content

Similar to newpython.pdfnewpython.pdfnewpython.pdf.

beginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdfbeginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdf
ElNew2
 
Will upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdfWill upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdf
sales223546
 

Similar to newpython.pdfnewpython.pdfnewpython.pdf. (20)

07012023.pptx
07012023.pptx07012023.pptx
07012023.pptx
 
Intro to OTP in Elixir
Intro to OTP in ElixirIntro to OTP in Elixir
Intro to OTP in Elixir
 
Python basic
Python basic Python basic
Python basic
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Python_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdfPython_Cheat_Sheet_Keywords_1664634397.pdf
Python_Cheat_Sheet_Keywords_1664634397.pdf
 
Revision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.docRevision Tour 1 and 2 complete.doc
Revision Tour 1 and 2 complete.doc
 
Basics of Python programming (part 2)
Basics of Python programming (part 2)Basics of Python programming (part 2)
Basics of Python programming (part 2)
 
Beyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCodeBeyond Breakpoints: Advanced Debugging with XCode
Beyond Breakpoints: Advanced Debugging with XCode
 
360|iDev
360|iDev360|iDev
360|iDev
 
かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版かとうの Kotlin 講座 こってり版
かとうの Kotlin 講座 こってり版
 
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
Elixir  -Tolerância a Falhas para Adultos - GDG CampinasElixir  -Tolerância a Falhas para Adultos - GDG Campinas
Elixir -Tolerância a Falhas para Adultos - GDG Campinas
 
dictionary14 ppt FINAL.pptx
dictionary14 ppt FINAL.pptxdictionary14 ppt FINAL.pptx
dictionary14 ppt FINAL.pptx
 
Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2Groovy puzzlers jug-moscow-part 2
Groovy puzzlers jug-moscow-part 2
 
2. Python Cheat Sheet.pdf
2. Python Cheat Sheet.pdf2. Python Cheat Sheet.pdf
2. Python Cheat Sheet.pdf
 
python cheat sheat, Data science, Machine learning
python cheat sheat, Data science, Machine learningpython cheat sheat, Data science, Machine learning
python cheat sheat, Data science, Machine learning
 
Beginner's Python Cheat Sheet
Beginner's Python Cheat SheetBeginner's Python Cheat Sheet
Beginner's Python Cheat Sheet
 
beginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdfbeginners_python_cheat_sheet_pcc_all (1).pdf
beginners_python_cheat_sheet_pcc_all (1).pdf
 
Beginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdfBeginner's Python Cheat Sheet.pdf
Beginner's Python Cheat Sheet.pdf
 
Will upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdfWill upvote asapPlease help my code gives me incorrect val.pdf
Will upvote asapPlease help my code gives me incorrect val.pdf
 

Recently uploaded

Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..
mvxpw22gfc
 
Call Girls in Sakinaka 9892124323, Vashi CAll Girls Call girls Services, Che...
Call Girls in Sakinaka  9892124323, Vashi CAll Girls Call girls Services, Che...Call Girls in Sakinaka  9892124323, Vashi CAll Girls Call girls Services, Che...
Call Girls in Sakinaka 9892124323, Vashi CAll Girls Call girls Services, Che...
Pooja Nehwal
 
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | DelhiFULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
SaketCallGirlsCallUs
 
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
delhimunirka444
 
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | DelhiFULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
SaketCallGirlsCallUs
 
FULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
FULL NIGHT — 9999894380 Call Girls In Badarpur | DelhiFULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
FULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
SaketCallGirlsCallUs
 
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | DelhiFULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
SaketCallGirlsCallUs
 
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
Business Bay Call Girls || 0529877582 || Call Girls Service in Business Bay Dubai
 
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
Business Bay Call Girls || 0529877582 || Call Girls Service in Business Bay Dubai
 
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Business Bay Call Girls || 0529877582 || Call Girls Service in Business Bay Dubai
 
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | DelhiFULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
SaketCallGirlsCallUs
 
FULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
FULL NIGHT — 9999894380 Call Girls In Kishangarh | DelhiFULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
FULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
SaketCallGirlsCallUs
 

Recently uploaded (20)

Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..Museum of fine arts Lauren Simpson…………..
Museum of fine arts Lauren Simpson…………..
 
Call Girls in Sakinaka 9892124323, Vashi CAll Girls Call girls Services, Che...
Call Girls in Sakinaka  9892124323, Vashi CAll Girls Call girls Services, Che...Call Girls in Sakinaka  9892124323, Vashi CAll Girls Call girls Services, Che...
Call Girls in Sakinaka 9892124323, Vashi CAll Girls Call girls Services, Che...
 
Moradabad Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
Moradabad Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service AvailableMoradabad Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
Moradabad Call Girls - 📞 8617697112 🔝 Top Class Call Girls Service Available
 
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
8377087607, Door Step Call Girls In Kalkaji (Locanto) 24/7 Available
 
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | DelhiFULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
FULL NIGHT — 9999894380 Call Girls In Dwarka Mor | Delhi
 
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
(9711106444 )🫦#Sexy Desi Call Girls Noida Sector 4 Escorts Service Delhi 🫶
 
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | DelhiFULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In New Ashok Nagar | Delhi
 
Akbar Religious Policy and Sufism comparison.pptx
Akbar Religious Policy and Sufism comparison.pptxAkbar Religious Policy and Sufism comparison.pptx
Akbar Religious Policy and Sufism comparison.pptx
 
FULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
FULL NIGHT — 9999894380 Call Girls In Badarpur | DelhiFULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
FULL NIGHT — 9999894380 Call Girls In Badarpur | Delhi
 
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | DelhiFULL NIGHT — 9999894380 Call Girls In Saket | Delhi
FULL NIGHT — 9999894380 Call Girls In Saket | Delhi
 
Hire 💕 8617370543 Mumbai Suburban Call Girls Service Call Girls Agency
Hire 💕 8617370543 Mumbai Suburban Call Girls Service Call Girls AgencyHire 💕 8617370543 Mumbai Suburban Call Girls Service Call Girls Agency
Hire 💕 8617370543 Mumbai Suburban Call Girls Service Call Girls Agency
 
Mayiladuthurai Call Girls 8617697112 Short 3000 Night 8000 Best call girls Se...
Mayiladuthurai Call Girls 8617697112 Short 3000 Night 8000 Best call girls Se...Mayiladuthurai Call Girls 8617697112 Short 3000 Night 8000 Best call girls Se...
Mayiladuthurai Call Girls 8617697112 Short 3000 Night 8000 Best call girls Se...
 
Barasat call girls 📞 8617697112 At Low Cost Cash Payment Booking
Barasat call girls 📞 8617697112 At Low Cost Cash Payment BookingBarasat call girls 📞 8617697112 At Low Cost Cash Payment Booking
Barasat call girls 📞 8617697112 At Low Cost Cash Payment Booking
 
Editorial sephora annual report design project
Editorial sephora annual report design projectEditorial sephora annual report design project
Editorial sephora annual report design project
 
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
UAE Call Girls # 971526940039 # Independent Call Girls In Dubai # (UAE)
 
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
Pakistani Dubai Call Girls # 971528960100 # Pakistani Call Girls In Dubai # (...
 
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
Dubai Call Girl Number # 00971588312479 # Call Girl Number In Dubai # (UAE)
 
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | DelhiFULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
FULL NIGHT — 9999894380 Call Girls In Patel Nagar | Delhi
 
FULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
FULL NIGHT — 9999894380 Call Girls In Kishangarh | DelhiFULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
FULL NIGHT — 9999894380 Call Girls In Kishangarh | Delhi
 
Completed Event Presentation for Huma 1305
Completed Event Presentation for Huma 1305Completed Event Presentation for Huma 1305
Completed Event Presentation for Huma 1305
 

newpython.pdfnewpython.pdfnewpython.pdf.

  • 1. #package and module #Module.py person = { "name":"john", "age":34, "country":"norway" } #file1.py import Module a = Module.person["name"] print(a) #class object and inheritance class animal: def speak(self): print("animal is speaking") class dog(animal): def bark(self): print("dog is barking") d = dog() d.bark() d.speak() #button widget from tkinter import * jayesh = Tk() jayesh.geometry("300x500") def akshay(): print("your button is clicked") B = Button(jayesh,text="hello",command=akshay) B.place(x=50,y=50) jayesh.mainloop() #string joining def ask(list_string): string="-".join(list_string) return string str1='vishal patil' list_string=ask(str1) print(list_string) #OR def ask(list_string): string="-".join(list_string) return string str1=["vishal","patil"] list_string=ask(str1) print(list_string)
  • 2. #arithmatic operators num1 =int(input("enter the first no:")) num2 =int(input("enter the second no:")) add = num1+num2 sub = num1-num2 div = num1/num2 mul = num1*num2 print(add) print(sub) print(div) print(mul) #Tuple my_tuple = () print(my_tuple) # Tuple having integers my_tuple = (1, 2, 3) print(my_tuple) # tuple with mixed datatypes my_tuple = (1, "Hello", 3.4) print(my_tuple) # nested tuple my_tuple = ("mouse", [8, 4, 6], (1, 2, 3)) print(my_tuple) #novision looping statement #for loop for i in range(0,5): print(i) #while loop count=0 while count<5: print(count) count=count+1 #nested for loop for i in range(1, 7): for j in range(i): print(i, end=' ') print() #function #simple function def newl(): print("hello my name is akshay") d=newl() #function with parameters def newl2(shila): return shila*2 jawani=newl2(7)
  • 3. print(jawani) #function with parameters which having default value def newl2(shila=14): return shila*2 jawani=newl2() print(jawani) #funiction in a function def outerFunction(text): def innerFunction(): print(text) innerFunction() outerFunction("hey!") #simple class and objects class Animal: def dog(self): print("dog is barking") d=Animal() d.dog() #list list1=[1,2,3,4,5,6,8] print(list1) type(list1)#min,len,sum,type #dictionaries dict={} dict[0]="hiii" dict[10]="bye" tinydict={"name":"akshay","age":23} print(dict) print(dict[0]) print(dict[10]) print(tinydict) print(tinydict["name"]) print(tinydict["age"]) #range function x = range(3, 20, 2) for n in x: print(n) #len function a=len("python") print(a) #lambda function x=lambda x:x*2 a=x(7) print(a)
  • 4. #max function max(1,2,3,4,5,7,5,10) #min function min(1,2,3,4,5,7,5,10) #sum function sum([1,2,3,4,5,6]) #config and resize from tkinter import * m =Tk() m.geometry("400x300") def on_button_click(): label.config(text="Hello, " + entry.get()) # Create the main window m.title("GUI Example") #m.minsize(200,100) # Create a Label widget label = Label(m, text="Welcome to Tkinter!") label.pack(pady=10) # Create an Entry widget entry = Entry(m, width=30) entry.pack(pady=10) # Create a Button widget button = Button(m, text="Click Me", command=on_button_click) button.pack(pady=10) # Configure options for resizing m.resizable(True,True)#0,0 # Set the initial size of the window # Run the main loop m.mainloop() #filter function def maxi(x): return x>4 l1=[2,3,4,5,6,7,8] newl=list(filter(maxi,l1)) print(newl) l1=[11,2,23,44,3,45] print(l1) #button widget from tkinter import * akshay=Tk() akshay.geometry("300x500") def file(): print("hello my name is akshay") B=Button(akshay,text="submit",command=file) B.place(x=50,y=50) akshay.mainloop()
  • 5. #entry widget from tkinter import * mayur=Tk() mayur.geometry("500x400") l1=Label(mayur,text="this is new program") l1.pack(side=LEFT) e1=Entry(mayur,bd=3) e1.pack(side=LEFT) mayur.mainloop() #frame widget from tkinter import * mayur=Tk() mayur.geometry("500x400") frame=Frame(mayur) frame.pack(side=BOTTOM) Blue=Button(frame,text="hello",fg="white",bg="blue") Blue.pack(side=LEFT) Green=Button(frame,text="hello",fg="white",bg="green") Green.pack(side=LEFT) Red=Button(frame,text="hello",fg="white",bg="red") Red.pack(side=LEFT) yellow=Button(frame,text="hello",fg="white",bg="yellow") yellow.pack(side=LEFT) mayur.mainloop() #checkbutton widget from tkinter import * drive=Tk() drive.geometry("400x300") checkvar1=IntVar() checkvar2=IntVar() ch1=Checkbutton(drive,text="pizza",variable=checkvar1,height=5,width=5) ch2=Checkbutton(drive,text="fries",variable=checkvar2,height=5,width=5) ch1.pack() ch2.pack() drive.mainloop() #canvas widget from tkinter import * flight=Tk() flight.geometry("400x300") C=Canvas(flight,bg="cyan",height=100,width=100) coord=10,50,90,70 arc=C.create_arc(coord,start=0,extent=97,fill="black") line=C.create_line(10,10,50,70,fill="white") C.pack() flight.mainloop() #list widget from tkinter import * listy=Tk()