President Obama may have been "really looking forward to getting out of D.C.," but a town-hall meeting in Minneapolis on Thursday concluded with an impassioned defense of the federal government.

The president is spending two days in the Twin Cities, and he and aides had said the trip was an opportunity to escape the nation's capital and hear from real Americans.

"I always tease them, I'm like a caged bear, and every once in awhile I break loose. And I'm feeling super loose today," Obama joked. "You don't know what I might do."

But as he fielded questions from what the White House described as "a cross section of community members," Obama became defensive of the work accomplished by federal employees and national politicians.

He said that federal programs like flood insurance were vital to communities, noting recent Midwestern storms and a rising Mississippi River had causing damage throughout the region. And, Obama said, it was the federal government's data that enabled innovations like weather apps on smartphones.

"That whole idea that government is the problem or the enemy is just not true," Obama said.

The president said he was frustrated by those who bashed federal workers, and attributed the economy's sluggish recovery partially to reluctance by state and local governments to resume hiring.

While some federal workers "do bone-headed things," Obama conceded, possibly referring to the scandal over lost IRS emails, he argued private sector workers did as well.

Obama also said he understood that amid tough political battles it would be easy for everyday Americans to "feel as if sometimes you're forgotten." But the president encouraged Americans to remain invested in Washington.

"Cynicism is popular these days, but hope is better," Obama said.

Still, Obama did use the hour-long town hall to take some swipes at his political opponents.

Asked about reauthorizing the Higher Education Act, Obama said he couldn't guarantee the legislation would get bipartisan support.

"Sometimes if I'm for it, then the other side is against it," Obama said.

He said of Republicans that their "only rationale and motivation appears to be opposing me," and predicted that some opposition lawmakers watching will "probably be saying I'm crazy or a socialist or something."

Obama also expressed frustration that members of Congress remained fearful to "vote their conscience" on gun rights, calling the legislative inaction after the Newtown, Conn., shooting the biggest disappointment of his presidency.

"Things are not going to change until the people against gun violence are as passionate and well organized as the NRA and the gun manufacturers," Obama said.