For the rotation, you can use either a rotation matrices, euler angles or quaternions. I would use the latter, since they don't have the problem with the gimbal lock. All of them are interchangable, but there are a lot of conventions, be aware of that!
The problem with Euler angles is that, there are a lot of them. This sounds a little bit odd, I know. What I mean is that there are various conventions, and you have to know which one you are currently using, otherwise you introduce errors. The figure below rotates around the z
(D) axis, then around the new x'
(C) axis and then z'
(B) axis.

Using quaternions, this problem can be avoided alltogether. Eventhough it introduces some new ones, such as more sophisticated math, but this is well explained in the links below and also implemented in various libraries in python.
The rotational axis around which the rotation is performed can be oriented arbitrarily, which is a great benefit. This comes in quite handy later on.
If you would like to see an algorithmic example of it, I suggest you have a look at this post. For the math, wikipedia might help.