Dynamic Mesh with color gradient based on height

I am trying to make a gravity simulation game with a dynamic mesh that reacts to masses, displacing the vertices in the z direction.
So far, I have vertices and I am using gl_LINES. The issue with this, is that assigning a color to each vertex makes the game lag a lot. I know that opengl has things called VBO’s and that would probably help with the color assignment, but I just started using opengl, and I am a new coder. I am working in python on a school project that is due in a few weeks, and was wondering if anyone has experience with 3d dynamic meshes.

the following links are photo examples:

what i have so far:


my goal: