The line, "moveForward(100);" moved main character Elsa 100 pixels to draw a square.
"You gotta slow down, 'cause I'm an old man," Obama told a student as she explained the program to him.
Interested parties can try it for themselves here.
The event came with several announcements from the White House, including commitments by more than 60 school districts to provide computer science education for students, steps to increase representation of minorities and women in computer science, and a new Advanced Placement Computer Science course from the College Board.
President Obama has long championed technology, engineering, and science as key points of education for American students.
The Obama White House has been pretty tech savvy over the years, becoming the first to truly harness the power of social media with accounts on Facebook, Twitter, and Instagram. Obama himself is the first president with a smartphone, though he has been mocked for sticking with a Blackberry.