The 7-year-old District boy who accidentally shot and killed his 3-year-old sister in July told homicide detectives that he thought his sister would “get up” after she was shot, “like they do on TV,” a prosecutor told a D.C. Superior Court judge Friday.

As she described the aftermath of the July 29 shooting of Dalis Cox, local prosecutor Kristi Browning’s voice quavered. She told the judge that the boy had told detectives that he was surprised his little sister had been killed.

“He said he didn’t know that would happen. He said guns on TV don’t do that,” Browning told the judge. “There was a break between reality and TV.”

The emotional disclosure came during the final hearing in a case that has left a community grieving a toddler’s death and officials and community leaders questioning how a gun could get into the hands of a child.

After the hearing, Browning said authorities considered the 7-year-old a “victim” as well.

Dalis Cox, shown in the undated family photo, died after she was shot by another child who was playing with a gun. (Family Photo)

But prosecutors did charge a 17-year-old male who admitted to bringing the loaded 9mm Glock pistol to the boy’s apartment. Inside the apartment, the 7-year-old found the gun in a bag and began playing with it. The boy fired the weapon, and a bullet struck his sister in the chest. The children’s mother was in another part of the apartment at the time.

In court Friday, the teenager was sentenced to a year of supervised probation. In September, the teen pleaded guilty to attempted second-degree cruelty to children and possession of an unregistered firearm.

The Washington Post generally does not identify juveniles charged with crimes. Despite objections from the teen’s attorney, The Post was permitted to attend the court hearing on condition that the teen, who was charged as a juvenile, not be identified.

Before the hearing, Judge Heidi M. Pasichow also ordered The Post not to identify any relationship between the teenager and the two younger children.

Browning told the judge that Dalis’s parents were not opposed to placing the teen on probation. Dalis’s father told the prosecutor that he wanted his daughter “to be remembered.”

At the hearing, the youth’s probation officer said the teen had been attending school regularly and has improved his grades since being allowed to return from the Department of Youth Rehabilitation Services. The teen is expected to graduate from high school in 2017 and told counselors that he hoped to attend college and major in electrical engineering.

The teen told authorities that he found the gun and wanted to take it off the streets before someone was hurt. Pasichow said she would not rule on the validity of his statement but said she found the teen was “doing everything he can to right the wrong in the best way he can.” In addition to the probation, she ordered the teen to undergo additional hours of therapy and grief counseling. She also ordered the teen to do 150 hours of community service, which includes speaking to teens and children about gun violence.

Dalis Cox, shown in the undated family photo, died after she was shot by another child who was playing with a gun. (Family Photo)

“It’s important for you to tell your story so other children can learn,” Pasichow said before allowing the teen to leave with his parents, who were in the courtroom.

Pasichow also reminded the teen — who had no prior convictions and who turns 18 next year — that for adults such charges carry stiffer penalties.

“I want you to internalize this process so you don’t come back as an adult,” she told the teen.

“Yes ma’am,” he said softly.