“The problem is there aren’t enough quality, free programs out there,” said Brandy McNeil, the library’s associate director of technology training programs. She added that the library, which currently has 10 technology instructors teaching coding, was seeking financing to expand the program and to hire additional instructors.

For students like Joshua Lee, 17, learning to code is another way to address issues in daily life. Joshua, who said he grew up watching young black men in his Harlem neighborhood get roughed up by the police, was part of the group of students who built the Protect & Swerve website and app during a Bronx hackathon in January.

“It creates a community for teens to gather together and learn and read about the topic and see it’s not overhyped,” he said.

Across the nation, Code.org, a nonprofit based in Seattle, has helped introduce coding to millions of students since 2013 through a grass-roots campaign every December in which people sign up to host an Hour of Code in their schools and communities. The campaign has grown to more than 198,000 organized events in 2015, up from 35,000 the first year, said Roxanne Emadi, a spokeswoman for the organization, which also trains teachers and provides curriculum for classrooms.

Nearly 400 schools held an Hour of Code as part of Code Brooklyn, a campaign started last summer by Eric L. Adams, the Brooklyn borough president, and Rob Underwood, executive director of Teach CS, which supports computer science training for teachers. Mr. Underwood said the campaign was currently surveying every school in Brooklyn to assess their readiness to teach computer science to students.