Nouns have two genders:
masculine (singular indefinite/definite article um / o)
feminine (singular indefinite/definite article uma / a)
Some nouns (professions, persons, animals) have both masculine and feminine form (E.g. a amiga and o amigo, a irmã (sister), o irmão (brother)).
Masculine
Usually words ending in -o are masculine.
Words ending in -ão are exceptions.
Feminine
Usually words ending in -a are feminine.
Exceptions are words borrowed from Greek (-ema, -ama and -oma, e.g. um telegrama, um sistema) and professions
(um jornalista ).
Words ending in -ção, -são, -stão or -gião are feminine (e.g. a televisão)
Words ending in -dade, -gem, -ie or -tude are feminine (uma mensagem, uma cidade)
From:https://www.dbfei.com/Article/putaoyayu/201311/8413.html