Jed Rembold
October 15, 2025
GArc class represents an arc formed
by taking a section of the perimeter of an oval.GArc class is a
GFillableObject, and so you can call
.set_filled() on a
GArc objectdef filled_arc():
gw = GWindow(400, 400)
arc = GArc(50, 50,
350, 350,
90, 135)
arc.set_color("orange")
arc.set_filled(True)
gw.add(arc)

Which of the below blocks of code will create the image to the right?
The window measures 500 x 200 pixels and the value of
d is 150.
x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, d, 90, -180)
gw.add(a1)
x, y = 250 - d, 100 - d
a1 = GArc(x, y, d, d, -180, 90)
gw.add(a1)
x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, d, 90, 180)
gw.add(a1)
x, y = 250 - d / 2, 100 - d / 2
a1 = GArc(x, y, d, 180, -90)
gw.add(a1)
GPolygon classGPolygons are
GFillableObjects, so they can be filledGPolygon function creates an
empty polygon, to which you then can add vertexes.add_vertex(|||x|||,|||y|||) on the
GPolygon object
x and y
measured relative to the reference point|||polygon|||.add_vertex(|||x|||,|||y|||)
adds another new vertex relative to the reference point|||polygon|||.add_edge(|||dx|||,|||dy|||)
adds a new vertex relative to the preceding vertex|||polygon|||.add_polar_edge(|||r|||, |||theta|||)
adds a new vertex relative to the previous using polar coordinatesdef triangle_by_vertex():
def create_triangle(b, h):
tri = GPolygon()
tri.add_vertex(-b / 2, h / 2)
tri.add_vertex(b / 2, h / 2)
tri.add_vertex(0, -h / 2)
return tri
gw = GWindow(500, 500)
triangle = create_triangle(200, 200)
triangle.set_filled(True)
triangle.set_color("red")
gw.add(triangle, 250, 250)
def triangle_by_polar_edge():
def create_eq_triangle(side):
tri = GPolygon()
tri.add_vertex(0, 0)
for i in range(0, 360, 120):
tri.add_polar_edge(side, i)
return tri
gw = GWindow(500, 500)
triangle = create_eq_triangle(100)
triangle.set_filled(True)
triangle.set_color("green")
gw.add(triangle, 250, 250)
GCompound class makes it possible to
combine several graphical objects so that the entire structure behaves
as a single objectGWindow and
GObject
GCompound,
you place them relative to the reference pointGCompound to a canvas,
you set the location of the reference pointdef my_axe():
def create_axe():
axe = GCompound()
shaft = GRect(-15, 0, 30, 300)
shaft.set_filled(True)
shaft.set_color("brown")
axe.add(shaft)
blade = GPolygon()
blade.add_vertex(0, 0)
blade.add_vertex(200, -50)
blade.add_vertex(200, 50)
blade.set_filled(True)
blade.set_color("gray")
axe.add(blade, -80, 50)
return axe
gw = GWindow(500, 500)
axe = create_axe()
gw.add(axe, 250, 100)
[, ]) with
commas separating each element of the sequence
['This', 'is', 'a', 'list']['Great', 4, 'storing', 5 * 10]Lists are commonly represented visually or conceptually as a series of numbered boxes:
COIN_VALUES = [1, 5, 10, 25, 50, 100]
COIN_NAMES = [ "penny", "nickle", "dime",
"quarter", "half-dollar", "dollar" ]
len function+ or
+=*in operatorcool = ['blue', 'violet']
warm = ['red', 'orange']
colors = [cool, warm]
other_colors = [['blue', 'violet'],
['red', 'orange']]
print(colors == other_colors)
print(colors is other_colors)
cool[0] = 'indigo'
warm = ['orange', 'yellow']
print(colors)
print(other_colors)