Is it possible to know by the type of transistor whether it is NPN or PNP?
For some types, yes. For example, Texas TIP series transistors have even numbers for NPN types and odd numbers for NPNs, for example, TIP31-NPN, TIP32-PNP, TIP41-NPN, TIP42-PNP. The BD series also include: BD135 - NPN, BD136 - PNP. However, it is not a general rule. For example, BC548, BC549 are NPN while BC558 and BC559 are PNP. The very best is to consult the datasheet.