If you divide nouns in those, which variate at the plural, and those, which don't, you have this "rule of thumb":
Variable names, regardless of their final letter, take the ending -i at the plural, with the exception of the feminine names which end in -a. These ones take the -e ending (ragazza -> ragazze, porta -> porte).
So,
l' attrice -> le attrici ( "actress", this is a feminine noun ending in -e, it variates at the plural and, as its singular doesn't end in -a, it takes -i at the plural),
il matematico -> i matematici (here, the last "c" is pronounced as "k" in the singular and as "ch", "č" at the plural),
il libro -> i libri,
la mano -> le mani (and this is a feminine noun which ends in -o! also: la radio, la moto and others)
il pilota (masculine, it ends in -a but is a masculine name, so not an exception to the rule) -> i piloti
la scatola (box) -> le scatole (again, a F. noun which ends in -a, so -e at the plural).
The names, which don't change... don't change XD and there are masculine and feminine nouns in this group.
In general, many nouns that end in -i are F. (analisi, prognosi, oasi...), with some exceptions, and these nouns don't change.
Foreign words don't change at the plural, even if a lot of people here do change them :(
Exceptions: some feminine nouns which end in -a at the singular take the ending -i at the plural.
L'arma -> le armi (weapon)
L'ala -> le ali (wing)
but also -e is permitted, although it sounds "old", "le arme", "le ale" and other similar forms are used in poetry for example.