Demo entry 6644491

Any shape

   

Submitted by anonymous on Oct 04, 2017 at 05:36
Language: Python. Code size: 958 Bytes.

#importing turtle
import turtle
import random

#Setting lettuce as the name
lettuce = turtle.Turtle()
#setting turtle shape to a turtle
lettuce.shape("turtle")

def pick_color():
    colors = ["blue","black","brown","red","yellow","green","orange","beige","turquoise","pink"]
    random.shuffle(colors)
    return colors[0]

def pick_color2():
    colors = ["blue","black","brown","red","yellow","green","orange","beige","turquoise","pink"]
    random.shuffle(colors)
    return colors[0]

colour2 = pick_color2()
colour = pick_color()
sides = int(input(": "))

lettuce.color(colour, colour2)

#defining shape and number of sides
def shape (shape):
    lettuce.pendown()

    lettuce.begin_fill()
    for i in range(sides):
        #pre determined length
        lettuce.forward(20)
        #determines angle
        lettuce.right(360/sides)
    lettuce.end_fill()
lettuce.penup()

#draws shape
shape (sides)

input()

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).