I'm a native speaker of Portuguese, know some English and have been studying German. I'm trying to understand the way the gender were assigned to nouns. I thought of this hypothetical situation: a homeschooled rich German boy, who never left his home, learned Standard German from the best teachers hired by his parents at home. Those teachers forgot or chose not to mention the word beggar, der Bettler, during their lectures, and the boy has never seen one neither. At the age of 18 he decides to go to Berlin, where he comes into contact with a beggar. The beggar introduces himself by saying: "Ich bin Bettler", and the boy answers: "Du bist also ein(e) Bettler?". Is there a logical way of assuming "Bettler" is masculine once it's an unbekown word?
Yes, because nouns denominating male persons ending on -er are grammatically always masculine. The female version of these is formed by adding -in, e.g., die Bettlerin. The only noun denominating a female person ending on -er I can think of is die Mutter.
By the way, there is absolutely no reason why it had to be a "soviet expatriate beggar" to leave out the article. Ich bin Bettler is Standard German.