Nostalgie: import turtle (langage Python)

Mes premiers essais furent en langage de programmation Basic sur TRS-80, puis en Logo, vers 1982!

De programmer avec la librairie turtle en langage Python… c’est de la nostalgie pour moi!

En utilisant le logiciel Visual Studio Code, c’était facile (contrairement à Spider!)

import turtle

t = turtle.Turtle()

turtle.getscreen()

t.right(90)
t.forward(100)
t.left(90)
t.backward(100)

Turtle()NoneCreates and returns a new turtle object
forward()amountMoves the turtle forward by the specified amount
backward()amountMoves the turtle backward by the specified amount
right()angleTurns the turtle clockwise
left()angleTurns the turtle counterclockwise
penup()NonePicks up the turtle’s Pen
pendown()NonePuts down the turtle’s Pen
up()NonePicks up the turtle’s Pen
down()NonePuts down the turtle’s Pen
color()Color nameChanges the color of the turtle’s pen
fillcolor()Color nameChanges the color of the turtle will use to fill a polygon
heading()NoneReturns the current heading
position()NoneReturns the current position
goto()x, yMove the turtle to position x,y
begin_fill()NoneRemember the starting point for a filled polygon
end_fill()NoneClose the polygon and fill with the current fill color
dot()NoneLeave the dot at the current position
stamp()NoneLeaves an impression of a turtle shape at the current location
shape()shapenameShould be ‘arrow’, ‘classic’, ‘turtle’ or ‘circle’

Published by:

Avatar de Inconnu

jasmin.tremblay

"Si tu veux construire un bateau, ne rassemble pas tes hommes et femmes pour leur donner des ordres, pour expliquer chaque détail, pour leur dire où trouver chaque chose... Si tu veux construire un bateau, fais naître dans le cœur de tes hommes et femmes le désir de la mer." Antoine de Saint-Exupéry

Laisser un commentaire

Laisser un commentaire