Trying to find an easier way to write my code. I am using the graphics.py module.
I will add the graphics program as an attachment for anyone who does not have it or doesn't know what I am talking about.

The first program I made is archery. Just simple circles and different colors. The second one is 5 dice. I'm trying to center everything and its not finished but has the basic code. I will post the dice program after this one. Convert graphics into a py file type.

from graphics import *

def main():

    win = GraphWin("Archery Target", 500, 500)
    
    shape1 = Circle(Point(250,250), 250)
    shape1.setOutline('white')
    shape1.setFill('white')
    
    shape2 = Circle(Point(250,250),200)
    shape2.setOutline('black')
    shape2.setFill('black')
    
    shape3 = Circle(Point(250,250),150)
    shape3.setOutline('blue')
    shape3.setFill('blue')
    
    shape4 = Circle(Point(250,250),100)
    shape4.setOutline('red')
    shape4.setFill('red')
    
    shape5 = Circle(Point(250,250),50)
    shape5.setOutline('yellow')
    shape5.setFill('yellow')
    
    shape1.draw(win)
    shape2.draw(win)
    shape3.draw(win)
    shape4.draw(win)
    shape5.draw(win)
    win.getMouse()
    win.close()
main()

This is the dice program. It is not finished. I am still working on it.

from graphics import *

def main():
    
    win = GraphWin("Dice",400,85,)
    
    shape = Rectangle(Point(10,10), Point(75,75))
    shape.setOutline("black")
    shape.setFill("white")
    shape.draw(win)

    cir = Circle(Point(42, 42.5), 3)
    cir.setOutline("black")
    cir.setFill("black")
    cir.draw(win)
    
    shape2 = Rectangle(Point(90,10), Point(155,75))
    shape2.setOutline("black")
    shape2.setFill("white")
    shape2.draw(win)

    shape3 = Rectangle(Point(170,10), Point(235,75))
    shape3.setOutline("black")
    shape3.setFill("white")
    shape3.draw(win)

    cir3 = Circle(Point(203, 42.5), 3)
    cir3.setOutline("black")
    cir3.setFill("black")
    cir3.draw(win)

    shape4 = Rectangle(Point(250,10), Point(315,75))
    shape4.setOutline("black")
    shape4.setFill("white")
    shape4.draw(win)

    shape5 = Rectangle(Point(330,10), Point(395,75))
    shape5.setOutline("black")
    shape5.setFill("white")
    shape5.draw(win)

    win.getMouse()
    win.close()
main()

Your programs are just sequence of actions with fixed constant parameters repeatedly used again and again. Use loops, variables and functions.

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.