web crawlers: Is blocking googlebot to access parts of the site with robots.txt penalized by Google?

I was reading this question.
Let's say I have a div with something useful for users but I do not want Google to take it into account.
If I put this in an iframe and block the googlebot with robots.txt so it does not read it. Would it be penalized?

Did Google ever clarify it? Or maybe from experience someone can confirm that it is okay to do it or not?