There's at least one obvious mistake with the code above:
The second line is overwriting the rotation, so no matter what you set as the yaw it's reset to 0 in the second line. Replace that line with
set_rotation(Vector3(deg2rad(pitch), deg2rad(yaw), 0))
When you want to store the orientation of something in 3d you have mainly three options:
1. You can store how many degrees something was rotated along which axis. That's very handy if you want to store one rotation, but if an object is rotated several times it's not easy to calculate that into one combined set of values.
2. You can store the orientation as a "quaternion", which is basically a more fancy way of doing the same as in option 1.
3. You can store the orientation as a combination of rotations around the x-, y- and z-axis. That solution has its own problems (the "gimbal lock" is the main one), but it's a lot easier to understand, especially if you want to combine several rotations.
That method is called "using Euler angles", and the three values aren't called x-rotation, y-rotation and z-rotation (unfortunately), they are called "yaw", "pitch" and "roll".
Afaik those words are taken from ships or airplanes. (http://www.aerospaceweb.org/question/dynamics/yaw/controls.jpg)
fmod is a function that is the floating point equivalent of the mathematical modulo function.
When you divide 5 by 2 you get 2.5. If you do so using integer numbers you get 5/2=2, the rest of 0.5 is lost since it can't be stored without using floating point numbers. In school you would say that 5 divided by 2 is 2 "with a rest of 1". Modulo returns that rest, so 5 modulo 2 is 1, since 5 is 1 more than the next lower number that can be divided by 2.
Modulo is often used to create sequences of numbers that stay in a certain range. In this case for example the calculated angle is restricted to numbers between 0 and 360, since an angle of e.g. 410 would be identical to an angle of 50 (since 360 degrees is a full turn and there's no difference between turning 50 degrees and turning 50 degrees + a full turn).