Don't worry - this is very simple and a common question! The imperfect tense is used for 3 reasons. 1) Descriptions or states in the past e.g. llevaba un pantalón azul/ e.g tenía calor. 2) Actions in the past with no definite beginning or end e.g. mientras yo hablaba él leía un libro (note how there was no specific end to this action). 3) For habits in the past e.g. Todos los días se levantaba a las ocho, y después tomaba una ducha.The preterite is used for completed actions in the past. E.g. Ayer, Juan abrió la ventana.Now lets link both together (v simple) as sometimes you will have both tenses in the same sentence e.g. Ayer, Juan abrió la ventana porque tenía calor. Abrió is in the preterite as it is a completed past event (he opened the window and done). Tenía is in the imperfect tense because its describing the state of the person - he was hot.Now lets do an example. How would you say I went to the shop because I needed food (Fui a la tienda porque necesitaba comida)