Sisters Kimberly, 9, right, and Rebecca Yeung, 11, of Seattle, look on as President Obama examines their spacecraft project during the final annual White House Science Fair of Obama’s presidency, on April 13, 2016. (Ricky Carioti/The Washington Post)

With all the thoroughness of a science-fair judge, President Obama made his way through a maze of poster board and robotic contraptions, pausing to quiz the young scientists and inventors. He learned about a process to turn foam cups into glue, a special vacuum cleaner for a subway and a balloon “spacecraft” that two little girls used to launch a photo of their late cat, Loki, to the edge of space.

“That’s unbelievable!” Obama told Rebecca and Kimberly Yeung, who are 11 and 9 years old, respectively. “You guys are amazing!”

Obama hosted his final White House Science Fair on Wednesday, hobnobbing with young brainiacs and speaking of how their fearlessness and courage in attacking problems as diverse as subway trash and Ebola buoyed his optimism for the future. He said the science fair, which his administration started six years ago, provided him “with some of the best moments I have had as president.”

“There’s nothing that makes me more hopeful about the future than seeing young people like the ones who are here,” Obama said. “All of you are showing us grown-ups that it’s never too early in life to make a difference.”

The White House Science Fair aims to showcase the nation’s brightest young scientists and inventors, and more than 130 students exhibited their creations and projects this year.

A family with two young daughters documents their launch of a helium balloon attached to a Go-Pro camera, a Lego and a picture of their cat, Loki. (Winston Yeung)

The science fair is one of the more visible parts of the administration’s broader effort to elevate science, technology, engineering and math (STEM) education in the nation’s schools. The U.S. Department of Education released guidance Wednesday to local school districts on how they should direct federal money toward increasing STEM education.

The administration in 2012 set a goal of producing 1 million more college graduates in STEM fields by 2022, and it also has pushed computer coding in the classroom.

In his final State of the Union address, Obama said that he hopes the nation’s students have the opportunity to take “the hands-on computer science and math classes that make them job-ready on Day One.”

Jo Handelsman, associate director for science at the White House Office of Science and Technology Policy, said the administration has worked to increase the recruitment of women and minorities into STEM fields, where they have been historically underrepresented.

The push is not just because the Obama administration thinks diversity drives creativity; Handelsman said that if the nation fails to develop experts from traditionally underrepresented groups, there will be a critical shortage of STEM-trained workers.

“Diversity is important,” Handelsman said. “We need more STEM workers, and we need to recruit the best talent of the world, and some of the talent will come from people who have not been traditionally involved in STEM.”

Addressing the science-fair participants, Obama underscored that point, saying it is critical to encourage women to enter STEM fields: “We’re not going to succeed when we’ve got half the team on the bench. Especially when it’s the smarter half.”

He highlighted the work of several students, including Jacob Leggette, a 9-year-old from Baltimore who wrote to companies that make 3-D printers and offered to write reviews for them if they allowed him to sample their devices. The young engineer, wearing a bow tie, showed off a model of the White House he made with a 3-D printer and then said: “I have a question, Mr. President. Do you have a child science adviser?”

The young scientists who participated in this year’s fair included girls as young as 9, first-generation college students and young immigrants. Many of the projects they created started as attempts to address problems in their communities.

Members of a team from Baruch College Campus High, a public school in New York City, drew inspiration from their daily subway commutes, when piled-up trash on the tracks caused train delays. Students from the high school have worked on a special vacuum cleaner for the tracks, engineering a way for it to be controlled with a smartphone app; they built their own set of subway tracks to test a prototype. Obama was intrigued by their device, and they told him he could give it a try.

“You sure? I don’t want to break it,” he told a trio of New York City teens before he switched on the roaring vacuum cleaner, which sat beneath the Lincoln portrait in the State Dining Room.

“Whoa!” the president said.

A team from Horizon Community Middle School in Aurora, Colo., near Buckley Air Force Base, created a prosthetic limb to enable an amputee to continue an active lifestyle. They designed the limb and built it with the help of disabled veterans.

Others reached far beyond their own worlds. Olivia Hallisey, a high school junior from Connecticut, invented a quick test for Ebola that requires no refrigeration and takes 30 minutes to produce a result. She said seeing the Ebola crisis in the headlines — and the fear it generated — drove home how interconnected the world is and how important it is to address global health crises beyond the nation’s borders.

The Yeung sisters built a lightweight balloon craft that floated 70,000 feet above the Earth. The Seattle girls captured the craft’s journey on a GoPro camera as it went aloft with two passengers: a picture of their late cat, Loki, and a Lego figure of the “Star Wars” character R2-D2.

Kimberly, an aspiring engineer, said she hopes their experience will inspire other girls to dig into science and engineering.

“Space and science and technology and things like that aren’t just things that boys are good at. It’s also girls, too,” Kimberly said. “Girls can be even better than boys.”