0% found this document useful (0 votes)
8 views2 pages

Python Turtle Commands

The document is a worksheet for Grade VII students at Hiranandani Foundation School International, focusing on computational thinking using Python's turtle library. It includes basic turtle commands for movement, pen control, and shape filling, along with example code for drawing shapes like squares. Additionally, it provides exercises for students to practice drawing a triangle, circle, multiple squares, and a pentagon using the turtle graphics module.

Uploaded by

rohhil.sinharoy
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)
8 views2 pages

Python Turtle Commands

The document is a worksheet for Grade VII students at Hiranandani Foundation School International, focusing on computational thinking using Python's turtle library. It includes basic turtle commands for movement, pen control, and shape filling, along with example code for drawing shapes like squares. Additionally, it provides exercises for students to practice drawing a triangle, circle, multiple squares, and a pentagon using the turtle graphics module.

Uploaded by

rohhil.sinharoy
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

Hiranandani Foundation School International

2024-2025

SUBJECT: Computing UNIT NAME- Computational GRADE– VII 5 December,2024


thinking- Python -turtle library

STUDENT`S NAME: DIV: Worksheet No.- 19

Link to test python turtle code

[Link]

Basic Turtle Commands

Here are some basic commands to control a turtle in Python's Turtle graphics module:

❖ Movement:
➢ forward(distance): Moves the turtle forward by the specified distance.
➢ backward(distance): Moves the turtle backward by the specified
distance.
➢ right(angle): Turns the turtle 1 right by the specified angle in degrees.
➢ left(angle): Turns the turtle left by the specified angle in degrees.
❖ Pen Control:
➢ penup(): Lifts the pen, so the turtle doesn't draw while moving.
➢ pendown(): Lowers the pen, so the turtle starts drawing again.
➢ pensize(width): Sets the width of the pen.
➢ pencolor(color): Sets the color of the pen.
➢ speed(speed): Sets the speed of the turtle's movements.
❖ Shape and Fill:
➢ shape(shape): Sets the shape of the turtle (e.g., "turtle", "arrow", "circle").
➢ fillcolor(color): Sets the fill color.
➢ begin_fill() and end_fill(): Starts and ends filling a shape.

1 | Page
Example of using above commands

#Draw a square #Draw color filled square


import turtle import turtle

# Set up the screen screen = [Link]()


screen = [Link]() [Link]("white")
[Link]("white")
pen = [Link]()
# Create a turtle object [Link]("red")
pen = [Link]()
pen.begin_fill()
# Loop to draw the square
for i in range(4):
for i in range(4): [Link](100)
[Link](100) [Link](90)
[Link](90)
pen.end_fill()
# Finish drawing 1q
[Link]() [Link]()

Exercise

1. Draw a Triangle
Modify the program to draw a triangle with three sides, each of length 100 units.

2. Draw a Circle
Write a program that uses Turtle to draw a circle with a radius of 50 units.

3. Draw Multiple Squares


Write a program that draws 4 squares in a row. Each square should be drawn at a 90-degree
angle from the previous one, and the size of each square should decrease by 20 units.

4. Draw a Pentagon
Create a Python program to draw a regular pentagon with each side of length 80 units.

2 | Page

You might also like