1).
Turtle attributes
Color : This attribute specfies the color of turtle. Default
turtle color is black.
Heading : Specified in degees the heading of the turtle. The
heading increases(i.e +ve value ) as turtle turn to left or
anticlockwise direction. Negative value means a right
direction or clockwise turn. Initially turtle facing east i.e 0
degrees.
Width: this is width of line drawn as turtle [Link] width
is 1 pixel.
Down : this artibute controls whether turle’s pen is up or
down. True or false are the values accepted. True(pen down)
means turtle draws when it moves. False(pen up) means
turtle don’t draw when moved.
2.) program to draw hexagon which is filled with red
color
import turtle as tt
t=[Link]()
t.begin_fill()
[Link]('red')
for i in range(6):
[Link](50)
[Link](60)
t.end_fill()
3). Python script to convert a set of images in the current
directory to grayscale.
import os
from PIL import Image
for f in [Link]('.'):
if [Link](".jpg"):
a=[Link](f)
gray=[Link]('L')
fn,fext=[Link](f)
[Link]("grayscale/{}_grayscale.jpg".format(fn))
4) Python GUI program to add two numbers.
from tkinter import *
def add():
a=float([Link]())
b=float([Link]())
result=a+b
d="result: "+ str(result);
[Link](text=d)
root=Tk();
[Link]("add two numbers")
numb1=Label(root,text="number 1")
entry1=Entry(root)
numb2=Label(root,text="number 2")
entry2=Entry(root)
result=Button(root,command=add,text="Result");
resultlabel=Label(root,text="result");
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
mainloop()