0% found this document useful (0 votes)
5 views3 pages

Module Test

The document describes turtle graphics attributes such as color, heading, width, and pen status, along with example programs for drawing a red hexagon, converting images to grayscale, and creating a GUI for adding two numbers in Python. The turtle program uses loops to create shapes, while the image conversion script utilizes the PIL library. The GUI program employs Tkinter to create a simple interface for user input and displaying results.

Uploaded by

josiah benny
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

Module Test

The document describes turtle graphics attributes such as color, heading, width, and pen status, along with example programs for drawing a red hexagon, converting images to grayscale, and creating a GUI for adding two numbers in Python. The turtle program uses loops to create shapes, while the image conversion script utilizes the PIL library. The GUI program employs Tkinter to create a simple interface for user input and displaying results.

Uploaded by

josiah benny
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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()

You might also like