Ten years ago, girls were so scarce in high school computer science classes that the number of female students taking Advanced Placement tests in that subject could be counted on one hand in nine states. In five others, there were none.
Now, an expansion of AP computer science classes is helping to draw more girls and underrepresented minorities into a field of growing importance for schools, universities and the economy.
Testing totals for female, black and Latino students all doubled in 2017, following the national debut of an AP course in computer science principles. It joined a longer-established AP course focused on the programming language Java.
Racial and gender imbalances persist. But education leaders said the data show a significant advance in a quest to banish the stereotype that computer science is mainly for coding geeks who tend to be white or Asian American boys.
"We're trying to diversify a field that for whatever reason has remained not so for generations," said David Coleman, president of the College Board, which oversees the AP program. "Really, what this is about is computer science breaking out of its narrow role."
Coleman acknowledged: "There's more work to do."
About 27 percent of roughly 100,000 AP computer science test-takers last spring were girls. Black students accounted for 5 percent of those tested and Latino students for 15 percent, well below their overall shares of school enrollment.
The quest to broaden the computer science talent pool hinges, in many ways, on stoking the passion of students such as Adesoji Adenusi and Daijah Etienne to explore the power of programming.
The two Maryland teenagers were hunting one recent morning for commands in Java to maneuver a wheeled robot, known as the Finch, through left-handed turns along the edges of a square floor mat. Keeping the gizmo on track was not easy.
At the keyboard, Adenusi toyed with numbers for wheel velocity. "A couple extra zeros never harmed anybody," he joked.
"It depends," shot back Etienne as she walked with the balky little robot. "What if you put a couple extra zeros on a check?"
Adenusi, 18, and Etienne, 17, both seniors, are in the Java-centered class called AP Computer Science A at Charles H. Flowers High School in Prince George's County.
Adenusi, who aims to major in computer science in college, said he is drawn to video-game design and has developed an appreciation for the precision and creativity the subject demands. "Everything really in coding is a choice," he said. "Colors, shapes, sizes — that's all up to you."
Etienne, who is considering studying computer engineering in college, also took AP Computer Science Principles in the past school year. She said the courses have deepened her understanding of the power of software to make objects come to life. "An iPhone, for example," she said. "A block of metal, in all honesty. But when you add the coding, it becomes something more."
At Flowers High, 86 students took an AP computer science test in the spring. That was more than triple the total of 26 in 2016. The new principles course fueled the growth. Most of the school's students are African American. Nearly half of those enrolled in AP computer science are girls.
College Board data show that 20 high schools in Maryland, Virginia and the District notched gains in 2017 of at least 50 students in AP computer science testing, compared with the previous year. Thomas S. Wootton High in Montgomery County had the largest growth: Its students took 238 of the exams, up from 76 in 2016.
Universities are tracking these developments closely because they have struggled for years to broaden the demographic base of students in computer science beyond white and Asian American men. The AP program, which enables students to obtain college credit through testing, offers one of the strongest links between high schools and higher education.
For more than 30 years, high schools have offered AP classes in computer science. But about 10 years ago, educators began to worry about participation. Overall numbers were low. About 20,000 students took the computer science tests in 2007, fewer than the totals for AP French or studio art.
A closer look showed even more dismal trends that year: Only about 3,360 female and 1,300 Latino students took the computer science tests. The African American total was a mere 734.
Trevor Packer, senior vice president of the College Board and longtime head of the AP program, said annual reports on computer science testing in that era would make him wince. Idaho, for example, counted 25 boys taking the tests in 2007 — and zero girls.
With help from the National Science Foundation, the College Board and computer scientists at various universities fashioned a new course meant to appeal to a broader audience. AP Computer Science Principles, or CSP, launched nationally in fall 2016.
A College Board video promoting the course made explicit appeals to underrepresented students. "A lot of girls are intimidated because they see computers as, like, a 'guy thing,' " one girl says in the video. "If more girls were, like, encouraged, then that wouldn't be an issue anymore."
Last spring, 92 girls from Idaho took an AP computer science test. Most were in Computer Science Principles.
Owen Astrachan, a professor of the practice of computer science at Duke University who helped develop the new class, said it is meant to complement Computer Science A.
"In CSA, it's all programming, all the time," Astrachan said. "In CSP, programming is part of it, but it's not the center of it." Students have more freedom to design their own projects in CSP. They are assessed at the end of the course on a digital portfolio of work — including a task focused on creating a computer program — as well as a multiple-choice test.
Duke gives credit to students who get a top score of 5 on the new exam or scores of 4 or 5 on the original computer science exam, allowing the students to place into higher-level courses. "I'm a big fan of trying to empower high schools," Astrachan said.
Expanding computer science in high schools takes more than adding a new AP course. It also requires investing in teachers, who often are not experts in the field. Course offerings have long been skimpy in many schools. In 2014, The Washington Post found that fewer than 1 in 10 high school students in the Washington region were taking a computer science course.
College professors, mindful of these issues, aim to help.
David J. Malan, who teaches a popular introductory course in computer science at Harvard University, said a version of it tailored to the AP CSP curriculum is available online for high school teachers who want to mine it for problem sets and homework assignments. The goal, he said, "is broadening access to and interest in computer science."
At Flowers High, Marilyn Fitzpatrick has taught computer science for five years. She said she wants students to see connections from the classroom to the working world in disciplines such as software development and cybersecurity.
"I try to engage them all," she said. "We need more minorities in the field."
On this December morning, her computer science classes were bustling with students who programmed robots — including a daredevil racing device with nubby tires called an Ollie — and completed self-paced assignments at terminals.
On the walls were posters with inspirational quotes, including one from President Barack Obama: "Don't just play on your phone, program it."
Christian Vasquez Rubio, 15, a sophomore in CSP, fiddled with coding commands for an Ollie to navigate an obstacle course. He said it was his first AP class. "This is a fun way to learn," he said. "I like it when we're able to do hands-on stuff."
Vasquez Rubio said he's intrigued by careers related to computer science. "I don't know what exactly, but somewhere in the field." And college? "Of course," he said. "That's a big goal of mine."