How do I set gravity?

I know how to make my player fall to the ground but I have no idea how to make him jump whenever I press space.

is there any special function for the gravity or do I have to make my own? if so, can you guys give me an example?

What physics engine are you using?

There is physics engine in Panda3D? can you post a link to that page?

But is there any way to use something like a getZ() to make my player able to jump?

There is no need for a physics engine. It’s basic math. Gravitational acceleration on earth is roughly 9.81 m/s², so to calculate the vertical speed in a given frame:

GRAVITY = -9.81
self.z_speed += GRAVITY * globalClock.getDt()

# Assuming ground plane is at 0 - substitute for airborne check or ground check
self.character.setZ(max(self.character.getZ() + self.z_speed * globalClock.getDt(), 0))

Then to cause the character to jump, just give it an initial upwards velocity, to simulate a momentary force being applied.