Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
turtle module
#1
Hi;

Can you please help me eith the code in below? I want to draw five square that touch to each other on their upper-right corners, but I am not able to do this. Ia m waiting your helps:




import turtle

def drawSquare(t, sz, dg):
    for i in range(4):
        t.forward(sz)
        t.left(dg)


wn = turtle.Screen()
wn.bgcolor("red")

tess = turtle.Turtle()
tess.pensize(3)


def WholeJob (a,b):
    for i in range(5):
        drawSquare(tess, 50, 90)
        tess.penup()
        tess.goto(a,b)
        tess.pendown()

WholeJob(50, 50)



wn.exitonclick()
Reply
#2
I added a few turtle moves
import turtle
turtle.setup(900, 600, 200, 100)

def drawSquare(t, sz, dg):
    for i in range(4):
        t.forward(sz)
        t.left(dg)
 
 
wn = turtle.Screen()
wn.bgcolor("red")
 
tess = turtle.Turtle()
tess.pensize(3)
 
 
def WholeJob (a,b):
    for i in range(5):
        drawSquare(tess, 50, 90)
        tess.penup()
        tess.forward(50)
        tess.left(90)
        tess.forward(50)
        tess.right(90)
        tess.pendown()
 
WholeJob(50, 50)
 
 
wn.exitonclick()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  setup() from turtle module not working bobfat 7 6,097 Oct-28-2019, 11:05 AM
Last Post: newbieAuggie2019
  wn = turtle.screen() AttributeError: module 'turtle' has no attribute 'screen' Shadower 1 6,171 Feb-06-2019, 01:25 AM
Last Post: woooee
  Help! Turtle not working, even when we click the turtle demo in IDLE nothing happens. BertyBee 3 5,616 Jan-04-2019, 02:44 AM
Last Post: SheeppOSU
  python turtle module in pycharm error sajley 2 13,081 Dec-12-2016, 08:52 PM
Last Post: sajley

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020