Random turtle shapes with python


#1

Hey can someone help me with this code I'm writing? it says there is something wrong with the semi colons and the range function at the bottom. can't figure it out. any help would be much appreciated. thanks!

import random

def drawRandom():
    x = random.randrange(-;200, 200)
    y = random.randrange(-;200, 200)
    length = random.randrange(75)
    shape = random.randrange(1,4)

    moveTurtle(x,y)

    if shape == 1:
        drawSquare(length)
    elif shape == 2:
        drawTriangle(length)
    elif shape == 3:
        length = length % 4
        drawCircle(length)
   
import turtle

def drawShape(sides, length):
    angle = 360.0 / sides
    for side in range(sides):
        turtle.forward(length)
        turtle.right(angle)
        
def moveTurtle(x, y):
    turtle.penup()
    turtle.goto(x, y)
    turtle.pendown()
    
def drawSquare(length):
    drawShape(4, length)
    
def drawTriangle(length):
    drawShape(3, length)
    
def drawCircle(length):
    drawShape(360, length)

for shape in range(100):
    drawRandom()
turtle.done()

#2

Python doesn't use semi-colons very much, perhaps what's wrong is that they are in your code at all?


#3

hey it works! thanks!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.