from tkinter import *
from tkinter import messagebox # importing message box
import random # importing random to create radom colors
global count
count=0 #local variable for counting clicks
root=Tk() #creating window
[Link]("colour buttons") # title of window
colours = ['Red','Blue','Green','Pink','Black', 'Yellow','Orange','White','Purple','Brown']
#colors on each click
def colo(): #function to counting clocks
global count
count+=1
[Link](colours)
[Link](bg = str(colours[0]))
if(count%5==0):
#message box if count =5
[Link]("5 clicks","5 clicks are done")
b=Button(root,text = "Click Me",command =colo,bg="blue")
[Link](row = 2, column = 2)
[Link]()
from tkinter import *
# import all the functions of ktinter
def comp(): #function invoked from submit button
x=[Link]()
if(x==1): # addition a+b
res=([Link]()+[Link]())
elif x==2: # difference a-b
res=([Link]()-[Link]())
else:
res=([Link]()+[Link]())/2 # average of a & b
[Link](res)
if(res<0):
[Link](fg="red") # changes color of text in result if <0
else:
[Link](fg="black")
root=Tk() # master window
[Link](" Compute")# change title from tk to compute
var1=IntVar()
var2=IntVar()
var=StringVar()
op=IntVar()
Label(master=root,font=4,text="a=").grid(row=0,column=0)#Label & grid to together
e1=Entry(root,bd=4,text=var1)# variable for Entry to use get function
[Link](row=0,column=1)
Label(master=root,font=4,text="b=").grid(row=1,column=0)
e2=Entry(root,bd=4,text=var2)
[Link](row=1,column=1)
# Radiobutton
Radiobutton(root,text="sum",variable=op,value=1).grid(row=2,column=0)# for addition
Radiobutton(root,text="diff",variable=op,value=2).grid(row=3,column=0)# for differnce
Radiobutton(root,text="avg",variable=op,value=3).grid(row=4,column=0)# for average
Button(root,text="Submit",font=4,bd=3,command=comp).grid(row=5,column=0)# submit
button to invoke comp function
Label(root, font=4,text="Result=").grid(row=6,column=0)
l1=Label(root,textvariable=var)
[Link](row=6,column=1)
[Link]()
file=open("[Link]","w")
[Link]("Hello\n how r u\n")
[Link]("Hii\n")
[Link]("hey\n")
[Link]()
a=open("[Link]","r")
lines=len([Link]())
print(lines)
file=open("[Link]","w")
[Link]("Hello how r u im good have a good day\n")
[Link]()
file=open("[Link]","r")
vowels = set("AEIOUaeiou")
cons = set("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ")
text = [Link]()
countV = 0
countC = 0
for V in text:
if V in vowels:
countV += 1
elif V in cons:
countC += 1
print("The number of Vowels is: ",countV,"\nThe number of consonants is: ",countC)
a=open("[Link]","w")
[Link]("Life is Beautiful\n")
[Link]()
a=open("[Link]","r")
cp=[Link]()
con=[Link]()
ep=[Link]()
[Link]()
print("Current position",cp)
print(con)
print("End position",ep)
week 12
import [Link] as plt
import numpy as np
x = [Link](50)
y = [Link](50)
[Link](x, y, s=70, facecolors='black', edgecolors='g')
[Link]("X")
[Link]("Y")
[Link]()
import [Link] as plt
x = ['Java', 'Python', 'PHP', 'JavaScript', 'C#', 'C++']
popularity = [22.2, 17.6, 8.8, 8, 7.7, 6.7]
[Link](x, popularity, color=['red', 'black', 'green', 'blue', 'yellow', 'cyan'])
[Link]("Languages")
[Link]("Popularity")
[Link]("PopularitY of Programming Language\n" + "Worldwide, Oct 2017 compared to a
year ago")
[Link]()