This is basic operation in WordPress, but it’s not as straightforward as you might think. For that, you will usually use get_posts() function that allows you to set category, but this function can use many more options than actually documented, you can use all WP Query arguments with it.
We will see how to exclude child categories from results and how to do a bit more with some other additional arguments this function can use.