3 Replies - 3290 Views - Last Post: 18 November 2012 - 09:57 AM Rate Topic: -----

#1 emma9873  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-November 12

How can i make this rectangle design into a loop?

Posted 17 November 2012 - 11:10 AM

def patchDesign2():
    win = GraphWin("Patchwork2", 100, 100)
    p1 = Point(0, 0)
    p2 = Point(10, 90)
    rectangle1 = Rectangle(p1, p2)
    rectangle1.draw(win)
    p3 = Point(0, 100)
    p4 = Point(90,90)
    rectangle2 = Rectangle(p3,p4)
    rectangle2.draw(win)
    p5 = Point(100, 100)
    p6 = Point(90, 10)
    rectangle3 = Rectangle(p5, p6)
    rectangle3.draw(win)
    p7 = Point(10, 10)
    p8 = Point(100, 0)
    rectangle4 = Rectangle(p7, p8)
    rectangle4.draw(win)
    p9 = Point(20, 80)
    p10 = Point(10, 10)
    rectangle5 = Rectangle(p9, p10)
    rectangle5.draw(win)
    p11 = Point(80, 80)
    p12 = Point(10, 90)
    rectangle6 = Rectangle(p11, p12)
    rectangle6.draw(win)
    p13 = Point(80, 20)
    p14 = Point (90, 90)
    rectangle7 = Rectangle(p13,p14)
    rectangle7.draw(win)
    p15 = Point(20, 20)
    p16 = Point(90, 10)
    rectangle8 = Rectangle(p15, p16)
    rectangle8.draw(win)
    p17 = Point(30, 70)
    p18 = Point(20, 20)
    rectangle9 = Rectangle(p17, p18)
    rectangle9.draw(win)
    p19 = Point(70, 70)
    p20 = Point(20, 80)
    rectangle10 = Rectangle(p19, p20)
    rectangle10.draw(win)
    p21 = Point(70, 30)
    p22 = Point(80, 80)
    rectangle11 = Rectangle(p21, p22)
    rectangle11.draw(win)
    p23 = Point(30, 30)
    p24 = Point(80, 20)
    rectangle12 = Rectangle(p23, p24)
    rectangle12.draw(win)
    p25 = Point(40, 60)
    p26 = Point(30, 30)
    rectangle13 = Rectangle(p25, p26)
    rectangle13.draw(win)
    p27 = Point(60, 60)
    p28 = Point(30, 70)
    rectangle14 = Rectangle(p27, p28)
    rectangle14.draw(win)
    p29 = Point(60, 40)
    p30 = Point (70, 70)
    rectangle15 = Rectangle(p29, p30)
    rectangle15.draw(win)
    p31 = Point(40, 40)
    p32 = Point(70, 30)
    rectangle16 = Rectangle(p31,p32)
    rectangle16.draw(win)


MOD EDIT: Added code tags. When posting code...ESPECIALLY Python code...USE CODE TAGS!!

:code:/>

This post has been edited by JackOfAllTrades: 18 November 2012 - 09:56 AM


Is This A Good Question/Topic? 0
  • +

Replies To: How can i make this rectangle design into a loop?

#2 tlhIn`toq  Icon User is online

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5674
  • View blog
  • Posts: 12,189
  • Joined: 02-June 10

Re: How can i make this rectangle design into a loop?

Posted 17 November 2012 - 12:21 PM

:code:

Collections. Array for example. Instead of having 30+ individual variables of rectangle## you could make an array of them, then loop through the array.
Was This Post Helpful? 0
  • +
  • -

#3 emma9873  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 17-November 12

Re: How can i make this rectangle design into a loop?

Posted 18 November 2012 - 03:38 AM

View PosttlhIn`toq, on 17 November 2012 - 12:21 PM, said:

:code:/>

Collections. Array for example. Instead of having 30+ individual variables of rectangle## you could make an array of them, then loop through the array.


I have never done an array, would it be possible to give me an example? Thanks alot
Was This Post Helpful? 0
  • +
  • -

#4 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6107
  • View blog
  • Posts: 23,657
  • Joined: 23-August 08

Re: How can i make this rectangle design into a loop?

Posted 18 November 2012 - 09:57 AM

Read the manual
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1