banner



What Two Turtle Methods Affect The Color Of A Turtle Drawing? (Choose Two.)

Introduction

Turtle graphics was role of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966 to teach students to code.

Y'all can use the CS50 Sandbox with the X Window pick to utilize Turtle Graphics.

Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an import turtle, give it the command turtle.forward(15), and it moves (on-screen!) fifteen pixels in the direction it is facing, cartoon a line as it moves. Requite it the command turtle.right(25), and it rotates in-identify 25 degrees clockwise.

Past combining together these and like commands, intricate shapes and pictures can exist drawn. Here's an example:

Circles with dissimilar colors

The start step in using Python's turtle graphics system is to import the turtle module. Allow's try using turtle in Python's interactive mode.

Python 3.7.1 ( default , Feb 20 2019 , 02 : 45 : 44 )

Blazon "assist" , "copyright" , "credits" or "license" for more than data .

Turtle Commands

Motion the turtle frontward past the specified distance , in the direction the turtle is headed.

turtle.backward( distance )

Movement the turtle backward by distance , opposite to the direction the turtle is headed.

Move turtle to the origin – coordinates (0,0) – and set its heading to its beginning-orientation.

Pull the pen upwards – no drawing when moving.

Pull the pen down – drawing when moving.

turtle.pencolor( colorstring )

Set pencolor to colorstring , which is a Tk color specification cord, such as "red", "yellow" etc.

Draw a circle with given radius .

Sets the turtle shape to turtle.

Disengage (repeatedly) the terminal turtle action(s)

Erases all drawings that currently appear in the graphics window.

Show Turtle

The Python turtle is initially position in the center of the graphics window. To display the turtle in the window, you can utilize the turtle.showturtle() command, to hide the turtle, you can use the turtle.hideturtle() control.

The Python turtle is initially positioned in the center of the graphics window. The arrowhead shows the direction that the turtle is currently facing. The default heading is 0 degree.

Event of the turtle.showturtle() command

Shapes

The turtle.shapes command sets the turtle shape to 1 of these shapes: "arrow", "turtle", "circle", "square", "triangle", and "classic".

>>> turtle . shape ( "turtle" )

Issue of the turtle.shape("turtle") command

Forward and Backward

The turtle.frontward( altitude ) or turtle.fw( distance ) and turtle.astern( distance ) or turtle.bk( distance ) moves the turtle frontwards or backward by the specified altitude , in the management the turtle is headed.

Event of the turtle.forward(100) command

Turning

You can turn the turtle to face a unlike management by using either the turtle.right(bending) or turtle.left(angle) command.

Outcome of the turtle.correct(xc) command

These are the angles in a Cartesian or 10-y airplane.

Pen Upwards and Downwardly

The turtle.penup() command pulls the pen upward so there will be no cartoon when the pen moves. The turtle.pendown() command pulls the pen down.

Drawing Circles

The turtle.circumvolve(radius) command makes the turtle draw a circle with a radius you specify. For example.

Result of the turtle.circle(100) command

Drawing Dots

The turtle.dot( size , color ) command draws unproblematic dots.

>>> turtle . dot ( 100 , "scarlet" )

Result of the turtle.dot(100, "cherry") command

Changing the Pen Size

You lot can utilize the turtle.pensize( width ) control to modify the width of the turtle's pen, in pixels.

Irresolute the Cartoon Colour

You lot can use the turtle.pencolor( color ) command to change the turtle's cartoon colour. The colour argument is the name of a color, equally a string.

>>> turtle . pencolor ( 'blood-red' )

Changing the Background Colour

You can use the turtle.bgcolor( color ) to change the groundwork color of the turtle's graphics window. The colour argument is the name of a color, every bit a cord.

>>> turtle . bgcolor ( 'green' )

Moving the Turtle to a Specific Location.

The pixel in the center of the graphics window is at the position (0,0)

Y'all can use the turtle.goto( ten, y ) command to move the turtle from its electric current location to a specific position in the graphics window.

If the turtle's pen is downwards, a line will be drawn equally the turtle moves.

Getting the Turtle's Current Position

Yous can use the turtle.pos() command to display the turtle's current position.

Displaying Text in the Graphics Window

You can use the turtle.write( text ) command to display text in the graphics window.

>>> turtle . write ( "Hi, World!" )

Result of the turtle.write("Hello, Globe!") command

Resetting the Screen

  • The turtle.reset() command erases all drawings that currently appear in the graphics window, resets the drawing color to blackness and resets the turtle to its original position at the center of the screen.

  • The turtle.clear() command erases all drawings that currently appear in the graphics window.

  • The turtle.clearscreen() command erases all drawings that currently appear in the graphics window.

Undo

The turtle.undo() command undoes the previous command.

Reference

Python 3's Turtle Graphics Reference Page

Source: https://www.pythonclassroom.com/turtle-graphics

Posted by: ramirezblaideselly.blogspot.com

0 Response to "What Two Turtle Methods Affect The Color Of A Turtle Drawing? (Choose Two.)"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel