As is often the case, our Swedish friend Hanna perfectly understands and explains English usage. The only points I would add:
(1) While it's traditional to describe ships, cars, airplanes, science-fiction spaceships, etc., as "she"; and sometimes also cities and countries and churches, it's ALWAYS acceptable to use "it" instead. "She" is never обязательно when speaking about inanimate or abstract objects.
(2) As Hanna said, it's not common to use "he" when talking about non-living things. However, note that in science fiction, robots with "human personalities" are most often "he", whether or not they physically resemble human males. For example, Commander Data from Star Trek is a "he", and so is C-3PO from Star Wars. But it might be less obvious that R2-D2 (who did not have a humanoid design, and spoke only in beeps) is also a "he", not a "she" or an "it". However, the "Evil Maria" robot from the film Metropolis, who inspired the design of C-3PO, was definitely a "she", because she had tits, and her name was "Maria"!
"He"
"He"
"She" (on the left)
Also "He", though for no logical reason...
There are TWO robots here (the humanoid robot, and the disc-shaped robot that the humanoid robot carried like a кулон around "his" neck) -- and they're both "He"!
P.S. However, I'm not sure whether Dr. Who fans would say that "The Dalek fired his weapon" or "The Dalek fired its weapon"!