0% found this document useful (0 votes)
19 views7 pages

Python Lab 5

The document contains Python programming exercises for drawing shapes using the turtle graphics library. Each program specifies the screen size, pen color, background color, pen size, and includes the student's SAPID in the output. The exercises include drawing a square, the letter 'E', concentric circles, a pentagon, and a specific figure with a black background.

Uploaded by

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

Python Lab 5

The document contains Python programming exercises for drawing shapes using the turtle graphics library. Each program specifies the screen size, pen color, background color, pen size, and includes the student's SAPID in the output. The exercises include drawing a square, the letter 'E', concentric circles, a pentagon, and a specific figure with a black background.

Uploaded by

rishiworkmail55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Python Lab 5

SAPID : 60005230003

Name : Rishi Bhansali

Date : 24/09/24

Class and Batch : M3-1

Program 16: Write a program to drawing a Square with sides of


length 100 pixel. The screen size should be 400x400, pen colour
should be red, background should be white, and pen size should be
5. Print your SAPID also in the output.

Program:

import turtle

t=turtle.Turtle()

s=turtle.Screen()

s.setup(400,400)

s.bgcolor("white")

t.pencolor("Red")

t.pensize(5)

for i in range(4):

t.forward(100)

t.right(90)

t.penup()

t.left(90)

t.forward(10)

t.ht()

t.write("60005230003",font=("Times",12))
Output: (Attach a screen shot)

Program 17: Write a program to draw letter ‘E’ as per 7 segment display.
The screen size should be 400x400, pen colour should be red,
background should be white, and pen size should be 5.Print your SAPID
also in the output.

Program:

import turtle

t=turtle.Turtle()

s=turtle.Screen()

s.setup(400,400)

s.bgcolor("white")

t.pencolor("red")

t.pensize(5)

t.backward(50)

t.right(90)

t.forward(50)
t.left(90)

t.forward(50)

t.backward(50)

t.right(90)

t.forward(50)

t.left(90)

t.forward(50)

t.speed(0)

t.penup()

t.right(90)

t.forward(20)

t.pendown()

t.ht()

t.write("60005230003",font=("Times",12))

Output: (Attach a screen shot)

Program 18: Write a program to draw concentric circles. The


screen size should be 400x400, pen colour should be red,
background should be white, and pen size should be 5. Print your
SAPID also in the output.
Program:

import turtle

t=turtle.Turtle()

s=turtle.Screen()

s.setup(400,400)

s.bgcolor("white")

t.pencolor("red")

t.pensize(5)

t.speed(0)

t.penup()

t.goto(0,-160)

t.pendown()

t.write(60005230003,font=("Time",12))

t.penup()

t.goto(0,-150)

t.pendown()

for radius in range(50, 150, 20):

t.penup()

t.goto(0,-radius)

t.pendown()

t.circle(radius)

t.shape("turtle")

Output: (Attach a screen shot)


Program 19: Write a program to draw a pentagon with sides 100
pixel long. The screen size should be 400x400, pen colour should be
red, background should be white, and pen size should be 5. Print
your SAPID also in the output.

Program:

import turtle

a=turtle.Turtle()

s=turtle.Screen()

s.setup(400,400)

s.bgcolor("white")

a.pencolor("red")

a.pensize(5)

a.speed(5)

for _ in range(5):

a.forward(100)
a.left(72)

a.penup()

a.goto(0,-50)

a.write(60005230003,font=("Time",12))

Output: (Attach a screen shot)

Program 20: Write a program to print the following figure. The


screen size should be 400x400, pen colour should be red,
background should be black, and pen size should be 5. Print
your SAPID also in the output.

Program:

import turtle

t=turtle.Turtle()

s=turtle.Screen()

s.setup(400,400)

s.bgcolor("black")

t.pencolor("red")

t.pensize(5)

t.speed(5)
t.setpos(-50,0)

for _ in range(4):

t.forward(100)

t.left(90)

t.penup()

t.forward(100)

t.pendown()

for _ in range(4):

t.forward(100)

t.right(90)

t.penup()

t.goto(0,-150)

t.color("white")

t.write(60005230003,font=("Time",12))

t.goto(-50,100)

t.shape("turtle")

Output: (Attach a screen shot)

You might also like