It is important for you to demonstrate a basic understanding of the subject matter before posting your question. If you're not sure where to start, definitely look to Trailhead, as that is a site geared towards learning the platform. Posts about basic platform functionality that is well documented are frowned upon (and usually negged). As long as you can show that you made an attempt to learn the subject matter, you should be fine.
How do I write a batch to do X?
I tried to write a batch to do X, but I got stuck because of error Y. Here's my code and the verbatim error message.
Always include error messages verbatim when you experience an error. It can be frustrating to come across a question that just says "it doesn't work" or "I got an error". It shouldn't be a guessing game here. The more specific you are about what you have tried and why it doesn't work, the better answers you will get.
The flip side of that specificity is, you should try to identify what portion of your code is relevant. The process of learning your own code well enough to pinpoint a specific function or query that is giving you trouble will make you a better programmer, and make your posts more broadly applicable. It's no fun to read through someone's 200 line controller when they really just needed help with one query.
How much research is enough? You should do as much research as practicable. If you can solve your own issue without a need to post it, that's a win! If that question has already been asked on the Salesforce Stack Exchange and the answer helped you, upvote both! If you found the answer elsewhere and want to share your discovery, then feel free to ask and answer your own question.
On that last point, I advise slight caution in making ask-and-answer posts while you are still a beginner. If you post an especially trivial finding, or if the general question has been answered many times on the exchange, you may receive a negative response. However, if you post such findings in good faith, we don't tend to be too harsh. As you gain more experience with both Salesforce and the Stack Exchange, you will get a better sense for which findings are trivial and which are meaningful.
A few updates from the comments
The best case scenario for your code snippets is that they will not be so wide or tall that we have to scroll to read it. I'd say width is marginally more annoying to scroll through than height. As a rule of thumb, that's ~90 characters to a line (92 if you want to push it) and ~38 lines.
That's not a lot of real estate, so make it count! Separation Of Concerns tends to make it easier to break out a few distinct snippets, if you have more relevant code than you can include in one such block. If you can't coherently organize distinct snippets, however, it is better to include one long block than several shorter ones that are hard to piece together.
I have a few recent examples of ask-and-answer you might find insteresting/instructive. I don't want to imply by any means I set the best example on the Stack Exchange network, but if it helps you find your way, I'm happy to help.
Looking forward to your contributions.