A:Answer 1. To answer your first question "Does the keyboard and pen drain battery in the surface pro 9?"
1a. The keyboard and pen are powered by the battery in the Surface Pro 9, however I would say it is negligible.
2. To answer your second question " Also what should I do to have a lasting battery bc I need it to last for school as a student"
2a. Use the recommended power settings Microsoft has in battery settings. Also using Edge instead of Chrome for a browser extends battery life. No mattery what you should expect it to last a whole school day. This thing also charges via USBC, so you can carry a small brick around with you in your backpack.
If you're getting this for school (I'm assuming college) in the fall, maybe wait and see if a surface pro 10 comes out. If you don't feel like waiting Best Buy has a pretty good deal right now.