0% found this document useful (0 votes)
15 views

Answer Key - Python Graphic WS 2

The document provides an answer key for a Python Graphic Worksheet aimed at Grade 8 students, detailing various turtle graphics programs to draw shapes. Each program utilizes loops and functions to create different shapes such as squares, stars, and spirals. The answers include code snippets demonstrating how to implement these graphics using the turtle module in Python.

Uploaded by

saritasstudents
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Answer Key - Python Graphic WS 2

The document provides an answer key for a Python Graphic Worksheet aimed at Grade 8 students, detailing various turtle graphics programs to draw shapes. Each program utilizes loops and functions to create different shapes such as squares, stars, and spirals. The answers include code snippets demonstrating how to implement these graphics using the turtle module in Python.

Uploaded by

saritasstudents
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Name: ___________________________________ Grade: 8 ______

Answer key - Python Graphic Worksheet


Drawing shapes using Python Programs (using loop wherever possible)

1.

Ans.
import turtle
t=turtle.Turtle()
t.penup()
t.setpos(-20,40)
t.pendown()
t.pensize(10)
t.pencolor("pink")
t.forward(100)
t.backward(100)
t.right(90)
t.forward(100)
t.left(90)
t.forward(100)
t.backward(100)
t.right(90)
t.forward(100)
t.left(90)
t.forward(100)
turtle.done()
2.

Ans. import turtle


star = turtle.Turtle()
for i in range(100):
star.forward(100)
star.right(144)
turtle.done()

3.

Ans. import turtle


mult_square=turtle.Turtle()
def Multiple_Squares(length, colour):
mult_square.pencolor(colour)
mult_square.pensize(2)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.forward(length)
mult_square.right(90)
mult_square.setheading(360)
for i in range(60,120,15):
Multiple_Squares(i,"blue")
turtle.done
4.

Ans. # import turtle


import turtle
screen= turtle.Screen()
# defining colors
colors = ['red', 'yellow', 'green', 'purple', 'blue', 'orange']
# setup turtle pen
t= turtle.Turtle()
# changes the speed of the turtle
t.speed(10)
# changes the background color
screen.bgcolor("black")
# make spiral_web
for x in range(200):
t.pencolor(colors[x%6]) # setting color
t.width(x/100 + 1) # setting width
t.forward(x) # moving forward
t.left(59) # moving left
t.speed(10)

5.
Ans.
# import turtle library
import turtle
t= turtle.Turtle()
my_wn = turtle.Screen()
t.speed(0)
for i in range(30):
t.circle(5*i)
t.circle(-5*i)
t.left(i)
t.exitonclick()

6.
Ans.
# import turtle
import turtle
mybg= turtle.Screen()
mybg.bgcolor("light blue")
t= turtle.Turtle()
t.color("black")
def mysq(size):
for i in range(4):
t.fd(size)
t.left(90)
size = size - 5
mysq(146)
mysq(126)
mysq(106)
mysq(86)
mysq(66)
mysq(26)
turtle.done()

7.
Ans.
# import the turtle modules
import turtle
# Start a work Screen
ws = turtle.Screen()
# Define a Turtle Instance
t = turtle.Turtle()
# executing loop 6 times for 6 sides
for i in range(6):
# Move forward by 90 units
t.forward(90)
# Turn left the turtle by 300 degrees
t.left(300)

********************

You might also like