atlast I have managed to get some working code but the first problem is that I have is taht.. when I call draw(2,4) I have a column of 2 circles and 4 rows and I would actually like it to be a clomun of 2 and row of 4. Secodly although my code works I have a main function and an input for an colour how could I fill the circles with the requested colour?

like
This is what i currently have
00
00
00
00

I want it like

0000
0000

from graphics import *
 
def main():
    colour = raw_input("Enter the colour: ")
 
def drawCircle(win, centre, radius, colour, color):
    circle = Circle(centre, radius)
    circle.setFill(colour)
    circle.setOutline(color)
    circle.draw(win)
 
def drawWindow(win, center, radius):
    drawCircle(win, center, radius, "white", "black")
 
 
def draw(rows, columns):
      radius = 50
      diameter = 2 * radius
      width = rows*diameter+1
      height = columns*diameter+1
      win = GraphWin("", width, height )
      for x in range( rows ):
         for y in range( columns ):
            xPosition = radius + 2 + diameter * x
            yPosition = radius + 2 + diameter * y
            center = Point( xPosition, yPosition )
            drawWindow( win, center, radius )
 
 
main()

Something strange in your code. It would only input one string and not using the value. Figure out where it should be used, pass the value to function in the parameters.

Something strange in your code. It would only input one string and not using the value. Figure out where it should be used, pass the value to function in the parameters.

ok and any help about displaying the circles in rows and columns?

You obviously use the loop variables in opposite meaning than you planned. rows are columns and columns are rows. Correct that.

something like this?

def main():
    colr = raw_input("Enter the colour: ")
 
def drawCircle(win, centre, radius, colour, color):
    circle = Circle(centre, radius)
    circle.setFill(colour)
    circle.setOutline(color)
    circle.draw(win)
 
def drawWindow(win, center, radius):
    drawCircle(win, center, radius, colr, "black")
 
 
def draw(rows, columns):
      colour=colr

No you have colr as local variable in function not as parameter. Main must call drawing routine with colr as added parameter.

Also drawWindow function serves no purpose. I would name parameters color and colour more descriptively.

Edited 6 Years Ago by pyTony: n/a

so do you mean this.. but how could I get main to call this function?

def drawCircle(win, centre, theColour, radius, colour, color):
    circle = Circle(centre, radius)
    theColour = raw_input("Enter the colour: ")
    circle.setFill(colour)
    circle.setOutline(color)
    circle.draw(win)

 
 
def draw(rows, columns):
      colour=theColour

Edited 6 Years Ago by gangster88: n/a

You have thcColour in parameter, but you are not getting the value of that before calling the function with user input as parameter.

This is how you call function:

def prod(a,b):
    return a*b

a= float(raw_input('Enter a: '))
b= float(raw_input('Enter b: '))
print 'The product is: ',prod(a, b)

Edited 6 Years Ago by pyTony: n/a

You have thcColour in parameter, but you are not getting the value of that before calling the function with user input as parameter.

This is how you call function:

def prod(a,b):
    return a*b

a= float(raw_input('Enter a: '))
b= float(raw_input('Enter b: '))
print 'The product is: ',prod(a, b)

I believe that the above is an example and does not fully apply to my code, I mean the multiplication of a and b. I have returned the "theColour" and then user inputs it and then colour= theColour?

def drawCircle(win, centre, theColour, radius, colour, color):
      circle = Circle(centre, radius)
      return theColour
      theColour = raw_input("Enter the colour: ")
      circle.setFill(colour)
      circle.setOutline(color)
      circle.draw(win)
 


      def draw(rows, columns):
      colour=theColour

Edited 6 Years Ago by gangster88: n/a

This question has already been answered. Start a new discussion instead.