J.R. S. answered 10/14/23
Ph.D. University Professor with 10+ years Tutoring Experience
I think most of this comes from experience, but you basically need to know something about Lewis structure, valence, octets, etc. Let's look at the examples given:
CH3NH2:
it can gain H and become CH3NH3+ but is not likely to lose H and become CH3NH so it would not be amphoteric
HSO4-:
It can gain H and become H2SO4 (sulfuric acid) and it can also lose H and become SO42- (sulfate anion) so it is amphoteric.
CN-:
It can gain H to become HCN (hydrogen cyanide, prussic acid), but it clearly can't lose H. It is not amphoteric.
H3O+:
It cannot gain H but it can lose H to become H2O. It is not amphoteric. H2O is amphoteric however as it can both gain H and become H3O+ or it can lose H to become OH-.