Skip to content

Learning Python using Turtle: Lesson 1 #3

@satishgoda

Description

@satishgoda

Module

import turtle
turtle
turtle?
dir(turtle)

dir is used to view the contents of a python object.

Just typing dir() will list the objects that are available for access via names in the current context/environment.

i = 10 # name i refers to an integer object with value 10
from turtle import Screen, Turtle
Screen?
screen = Screen()
screen
dir(screen)
screen.setup?
screen.setup(600, 600)
screen.setup(width=640, height=480)
screen.turtles?
screen.turtles()
turtles = screen.turtles()
turtles
Turtle?
turtle = Turtle()
turtles
turtle.color?
turtle.color('green')
turtle.shape?
turtle.shape('turtle')
turtle.forward(100)
turtle.home()
turtle.clear()
turtle.pencolor?
turtle.pencolor('red')
turtle.forward(100)
turtle2 = Turtle('triangle')
turtles
turtle2.color('red')
turtle2.pencolor('green')
turtle2.left(90)
turtle2.forward(100)
for item in turtles:
    item.forward(50)
for item in turtles:
    item.backward(50)
turtle2.undo()
turtle.undo()
for item in turtles:
    item.backward(50)
for item in turtles:
    item.undo()
for item in turtles:
    item.stamp()
    item.backward(50)
turtle2.clearstamp()
turtle2.clearstamp?
turtle2.clearstamps()
turtle.clearstamps()
turtle.screen
turtle2.screen
turtle.screen is turtle2.screen
screen
screen is turtle.screen is turtle2.screen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions