Translation:I took a pencil and wrote the task.
As others have said, this sentence is very unnatural in English. At least in American English, we don't normally use the word "task" to mean a writing assignment. I think, in this context, it would probably be better to translate задание as something like "assignment", "exercise", or "essay".
In English you do an exercise and complete a task - a task and an exercise have different meanings. I assum e задание refers to a scholatic assignment or exercise. If it refers to a teacher creating an exercise, it would be better to say that the teacher wrote or prepared the exercise/ assignment.
All translation, even for one just learning, needs to strike a balance between accuracy and fluidity. Yes, it's necessary to know that 'task' is one translation, but it's also necessary to find another meaning that sounds natural in English. It's similar to how we need to insert a/an/the to make the English sound right, even though such articles do not exist in Russian.
As a verb prefix, по- often conveys aspect (usually perfective) while на- can mean a lot of different things, like "onto", "completely", "a quantity of". However, this is not carved in stone! As explained in the tips and notes on prefixes: "Most Russian prefixes behave similarly to English prepositions when you add them to English verbs as particles. One's knowledge of English helps one guess what "turn up", "take off" or "run out" may mean. However, you can never be sure without a dictionary or a context that makes the meaning obvious (or you can ask someone to explain the word to you)."
Seems like a lot of languages say that one "writes" an exam/assignment, and I understand what is meant in the strictest sense. But in American English, to say someone "wrote" a test/task connotes having created it. Like the teacher/professor "writes" an exam, the students "take" or "do" it. Maybe that's a distinction without a difference in Russian but for English speakers it suggests something else.