I will answer the question, while ignore the computer programming language in question, as this is pretty much the same in all languages and the differences are technical.

The fundamental question is how one can represent geometry using computers, and circles or pyramids are just instances of geometry. One can represent geometry using equations. For example, the circle (a curve) of radius one around the origin could be represented using the following parametricequation form:

x = cos(t), y = sin(t), t between 0 and 360 (degrees).

Parametric form is very common in many geometric design systems such as Autocad and 3d studio max. There, parametric forms of two variables are typically used to represent surfaces. For example

x = cos(r) cos(t), y = cos(r) sin(t), z = sin(r), r between -90 and 90,t between 0 and 360,

defines a (what!?). In general, geometric design systems use special parametric forms, such as Bezier curves and surfaces, which are merely polynomial equations much like the above circle equation.

But all this is the internal representation used in geometric design systems. Many of these systems convert the equations into many polygons that approximate the equation.A polygon is a planar face and triangles are the simplest of all polygons, having only 3 vertices. Yet, with (many)triangles, one can approximate arbitrary complex geometry constructed of many equations. A square and/or a rectangle are two more examples of polygons (with 4 vertices).

A single polygon could be represented in the computer using its list of vertices, as (x1, y1), (x2, y2), …, (xn, yn). A polygon in 3D space will have a third, z, coordinate added to each of its vertices: as (x1, y1, z1), (x2, y2, z2), …, (xn, yn, zn).

A circle could be approximated using a polygon of n vertices:

n = 30 / n = 100

When n = 30, the samples and the line segments connecting adjacent samples are still visible. When n = 100, the circle looks good enough.

Similarly, a sphere could be represented using polygons (in 3D space, we are no longer in a 2D planar world):

200 polygons / 3200 polygons

Here, for the sphere, we have both 3-sided triangles and 4-sided polygons (can you identify both types?). Obviously, the denser we sample the equation (a sphere here), the better the approximation (of the sphere) is, yet we have many more polygons.

So by now we know how to represent a polygon and a circle (either as an equation or as samples - as many polygons approximating the circle) and even a sphere). A pyramid, like the sphere, will consist of several such polygons defining all its faces:

/ [OBJECT TETRA
[TRIANGLE
[1 1 1]
[-1 1 -1]
[1 -1 -1]
]
[TRIANGLE
[1 1 1]
[-1 -1 1]
[-1 1 -1]
]
[TRIANGLE
[1 1 1]
[1 -1 -1]
[-1 -1 1]
]
[TRIANGLE
[1 -1 -1]
[-1 1 -1]
[-1 -1 1]
]
]
A pyramid (Tetrahedron) / 4 triangles

On the right you can see the (x, y, z) coordinates of the four faces forming this Tetrahedron model.

So now how can one draw these 3D models (a sphere with many polygons or the tetrahedron with 4 triangles) on a 2D screen? This is a whole new interesting question by itself.

More can be found in classic books in computer graphics. See the computer graphics course's website at the Technion at some relevant books under'Literature'.