项目作者: simplonco

项目描述 :
Playing with a tiny turtle so cute :turtle: !
高级语言: Makefile
项目地址: git://github.com/simplonco/python-playing-turtle.git
创建时间: 2016-05-25T12:25:01Z
项目社区:https://github.com/simplonco/python-playing-turtle

开源协议:GNU General Public License v2.0

下载


Playing with Python Turtle

Teenage Mutant Ninja Turtles

Turtle is a python module, it allows you to draw shapes on the screen.
You control a cursor that you can move with the commands:

  1. import turtle
  2. turtle.forward(10) # 10 moves forward
  3. turtle.backward(10) # 10 moves backward
  4. turtle.left(90) # rotates 90 degrees cursor left
  5. turtle.right(90) # clockwise
  6. turtle.penup() # cursor up
  7. turtle.pendown() # cursor down

Here is an example of a program drawing a square:

  1. import turtle
  2. turtle.forward(100)
  3. turtle.left(90)
  4. turtle.forward(100)
  5. turtle.left(90)
  6. turtle.forward(100)
  7. turtle.left(90)
  8. turtle.forward(100)
  9. turtle.left(90)

A bit of style

You can customize your designs with different functions:

  1. turtle.speed(speed) # changes the cursor speed
  2. turtle.pensize(size) # changes the size of the line
  3. turtle.pencolor(red, green, blue)
  4. # each component is between 0 and 1

Installation

  1. sudo apt-get install python python-tk

To go further

WikiBook - Une tortue qui accélère la résolution de problèmes