MEMPHIS, Tenn. -- Rewarded with the president of the United States as their commencement speaker, the graduating seniors at Booker T. Washington High School got the same advice a young Barack Obama once got himself: Keep pushing.

"You've always been underdogs," the president told the cheering students, clad in green and yellow gowns, from a school where academic scores and graduation rates have soared despite tough conditions in the community. "Nobody's handed you a thing. But that also means that whatever you accomplish in your life, you'll have earned it," Obama said.

The high school won a national competition, and Obama's presence, thanks to its hard-fought academic turnaround. The school is in a gritty south Memphis community where many of its students live in tough neighborhoods beset by crime, drug addiction, teenage pregnancy and untreated mental illness. A majority of the students are poor, and some are homeless.

Obama told the smiling seniors: "You've shown more grit and determination in your childhoods than a lot of adults ever will."

The president personalized his graduation message, reminding the students his father left home when he was 2 and his mom raised him amid economic struggles. He said his mother and his grandparents stayed on him to excel.

"I'm lucky they kept pushing," Obama said. "I'm lucky my teachers kept pushing. Because education made all the difference in my life. And it's going to make an even greater difference in your lives."

After putting in place educational innovations and adding variety to its curriculum, the Memphis high school saw its graduation rate jump from 55 percent in 2007 to nearly 82 percent in 2010.

Changes at the school include separate freshmen academies for boys and girls and a greater choice of advanced placement classes.

Obama said the whole culture of the school has changed to one of caring and learning.

"That's why I came here today," he said. "Because if success can happen here at Booker T. Washington, it can happen anywhere in Memphis. And if it can happen in Memphis, it can happen anywhere in Tennessee. And if can happen anywhere in Tennessee, it can happen all across America."

Obama seemed to enjoy the moment as much as the students. He said he always treasures commencement ceremonies, but "this one is especially hopeful." And he thanked the students for inspiring him as president.

Obama spoke after privately offering comfort to Memphis area families affected by the Mississippi River's flooding; his trip had been scheduled before the flooding occurred.

White House press secretary Jay Carney said Obama met with the flood victims, local officials and first responders for about 35 minutes. Nanny Williams, an unemployed mother living with her daughter and granddaughter, described being flooded out of her house, forcing her family into a community shelter, Carney said. Another woman, Rose Hunt, told the president that prayer spared her house which became a refuge for her son, who had to abandon his home.

Snow melt and rain that have sent a torrent of water down the Mississippi, topping levees and forcing flooding along its path. The river crested at Memphis last week, just inches short of the record set in 1937. Some low-lying neighborhoods were inundated, but the city's high levees protected much of the rest of Memphis.