Showing posts with label Turtle. Show all posts
Showing posts with label Turtle. Show all posts

Christmas tree on Python on Turtle

Christmas tree on Python on Turtle
# Christmas tree on Python import turtle def line(x1, y1, x2, y2): turtle.penup() turtle.goto(x1, y1) turtle.pendown() turtle.goto(x2, y2) screen = turtle.Screen() screen.title("Christmas Fir tree") screen.setup(500, 500) # To turn the drawing upside down screen.setworldcoordinates(0, screen.window_height(), screen.window_width(), 0) turtle.pencolor('green') line(200,210,220,230) line(220,230,180,230) line(180,230,200,210) line(200,230,230,250) line(230,250,170,250) line(170,250,200,230) line(200,250,250,270) line(250,270,150,270) line(150,270,200,250) line(200,270,270,290) line(270,290,130,290) line(130,290,200,270) line(200,290,290,310) line(290,310,110,310) line(110,310,200,290) turtle.hideturtle() turtle.exitonclick()

This simple code example was intentionally made similar to Christmas tree on Pascal on Android

The Christmas tree on Python on Turtle is available in My Github Repository

GUIs with Tkinter (and Fun with Turtles)

Python Turtle Graphics
Turtle graphics is a popular way for introducing programming to kids. It was part of the original Logo programming language developed by Wally Feurzig and Seymour Papert in 1966.

The example that comes with the turtle docs:

from turtle import * color('purple', 'cyan') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done()

The example was found in the book "Head First Python, 2nd Edition" by Paul Barry, released November 2016, Publisher(s): O'Reilly Media, Inc.