Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 1.69 KB

File metadata and controls

36 lines (21 loc) · 1.69 KB

Project Title

Use aColor as part of the computation in a for-Loop in a turtle Module to create a square. Once this program is run aColor will take on any of the attributes of the turtle. All of the for-Loop compound statement is executed completely before going to the next sequential statement. wn.exitonclick() will close the window (canvas) when the it is clicked on with the mouse.

Getting Started

You will need a device and an operating system that is compatible with the required storage for the download of the software.

Prerequisites

Turtle Module (object) requires the installation of the latest version of Python 3.7.3 with the additional IDE of PyCharm to run code. OS systems include downloads for Windows, Linux/Unix, Mac OS X and other Platforms. See link below for complete details. If you do not have your own personal computer you can the interactive site Runestone Academy (link below)

Running

import turtle #imports the turtle module, set up Lexi

wn = turtle.Screen() #creates the turtle window

wn.bgcolor("lightgreen") #canvas background lightgreen

lexi = turtle.Turtle() #creates turtle named lexi

for aColor in ["yellow","red", "purple", "blue"]: #applies each color attribute to lexi using for-Loop iteration lexi.color (aColor)
lexi.forward(50) #moves lexi 50 pixels forward lexi.left(90) #moves lexi 90 pixels left to complete square

wn.exitonclick()

https://www.python.org/download (Click the installation that applies to your OS.) https://www.jetbrains.com/pycharm/ https://www.runestone.academy/

Thanks

Thans to Python Software Foundation, Runestone Academy, my instrucotr Zak.