How can I do the best assignments as being a computer science student?
I'm surprised by your question. In the first semester of a program you shouldn't already be expected to know much of anything. But you should be expected to learn a lot of things. 

But you learn by asking a lot of questions. Also by answering some of those yourself through reading. 

But the most important thing to do is to do a lot of exercises and have your professor give you feedback on how to make them better. 

To learn how to program you have to write a lot of programs and to think about why they work or why they don't. You have to learn how to use the tools and what information they give you. That also takes practice. 

I worry that you say your instructor insults you. Certainly some teachers do that, but perhaps they are really just criticizing your work. But they need to say more than just "this is bad". They need to give you some help on how to make it better. 

But, reading and listening to the instructor is not enough. You have to practice. The more you practice the better you get. Just like futbol. 

Depending on the rules imposed by your institution and professors, you might also consider forming a study group of fellow students so that  you can try to learn together. Some places don't allow it, of course, but it can be helpful when possible. But be careful not to give the impression that you are just copying assignments from one another. A study group has to be about learning.