Given a scientific question, generate a correct answer to it.

In chemical reactions, what substances can act like metals or nonmetals, depending on their number of electrons?
metalloids