Hi everyone
First post but I have been browsing as a guest for help with my university python project for a while now. There some really great help on here, Thank you!

Right I'm doing a beginners python programming unit as part of my uni course, and as part of that unit I have to do a project. This project being to create a pyramid consisting of 2 different "Patches" if you like, if you take a look below you can see on of the "patches" is finished (nestedCircles()), but as for the other "patch" (Diamonds()) I just cant work out how to do it, this is an example of the patch I have to do:-[IMG]http://img101.imageshack.us/img101/3275/diamondss.jpg[/IMG]

from graphics import *

def nestedCircles():
    win = GraphWin("Circles", 100,100)
    yValue = 51
    centre = Point(51.47,yValue)
    radius = 50
    circle1 = Circle(centre, radius)
    circle1.draw(win)
    for i in range(10):
        radius = radius - 5
        yValue = yValue + 5
        centre = Point(50,yValue)
        circle1 = Circle(centre, radius)
        circle1.draw(win)
nestedCircles()


def diamonds():
    win = GraphWin("Lines", 100,100)
    yValue = 20
    line1 = Line(Point(200,200), Point(900,900))
    line1.draw(win)
    for i in range(9):
        line1 = Line(Point(90,10), Point(5,3))
        line1.draw(win)

Any help with this would be soo gratefully received, don't forget I have only been doing python for 2 months now! :)

Regards
Joe

Recommended Answers

All 7 Replies

Just a little experiment, you can go from there ...

from graphics import *

def diamonds():
    win = GraphWin("Lines", 200, 200)
    #Line(Point(0, 0), Point(200, 200)).draw(win)  # test
    x = 0
    for y in range(0, 190, 20):
        x1 = x
        y1 = y
        x2 = 200
        y2 = 200
        print x1, y1, x2, y2  # test
        Line(Point(x1, y1), Point(x2 - y, y2)).draw(win)
        Line(Point(x2, y1), Point(x1 + y, y2)).draw(win)

    # pause for click in window
    win.getMouse()
    win.close()
    
diamonds()

Hi Vegaseat

Thanks for taking the time to reply.

I managed to get it to run eventually on my computer (The python graphics module has problems for some reason) it gave a good output and is defiantly a good base to start from, here is what it looked like:-
[IMG=http://img406.imageshack.us/img406/562/diamonds2.jpg][/IMG]
Thanks again

That's the one tonyjv, I don't think it likes my 64bit operating system as it more often than not, crashes, so I have to restart python

If you are using the 64 bit version of Python26 with modules like that, you can get into trouble, simply use the win32 version.

Will it be okay running on a 64bit OS?

Will it be okay running on a 64bit OS?

Yes!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.