President Trump on Friday repeatedly castigated an armed school resource officer who stayed outside during a deadly school shooting in South Florida last week, arguing that teachers with concealed weapons would be more committed to saving the lives of students.

As part of his pitch, Trump told a national gathering of conservatives that the carnage at Marjory Stoneman Douglas High School in Parkland, Fla., where 17 people were killed, would have been reduced if teachers could have confronted the gunman with a weapon.

“A teacher would have shot the hell out of him before he knew what happened,” Trump said during an address to the Conservative Political Action Conference, an annual conclave of the American right, held just outside Washington.

Speaking with reporters earlier Friday as he was leaving the White House, Trump said that the school resource officer, Scot Peterson, was either a “coward” or “didn’t react properly under pressure.”

Trump also took Peterson, a Broward County sheriff’s deputy, to task during his speech to the conservative gathering and later in the day at a joint news conference at the White House with visiting Australian Prime Minister Malcolm Turnbull.

“He was tested under fire, and there wasn’t a good result,” Trump said of Peterson at the first event. “He was not a credit to law enforcement, that I can tell you.”

Appearing later alongside Turnbull, Trump said the advantage of arming teachers — he’s suggested about 20 percent should carry concealed weapons — is that they “love their pupils.”

“See, a security guard doesn’t know the children, doesn’t love the children,” Trump said. “This man standing outside of the school the other day doesn’t love the children, probably doesn’t know the children.”

While Trump has pledged to take several actions in response to the Parkland shootings, including strengthening background checks for purchasing guns, he has been most animated in recent days about his idea of arming teachers.

The concept is staunchly opposed by the National Education Association, the country’s largest teachers lobby, as well as by some law enforcement officers.

Trump acknowledged that the notion is controversial, and he said that even some “good people” are opposed. But he said that some skeptics are starting to agree with him that schools should be “a much harder site for attackers.”

“We need a hardened site,” Trump said. “It needs to be hardened. It can’t be soft.”

For much of Trump’s address to the gathering of conservatives — which included references to his 2016 campaign victory and a claim that his administration has been the most successful in history — the crowd was rollicking.

At one point, when Trump mentioned his vanquished opponent, Democrat Hillary Clinton, the audience broke into a chant of “Lock her up!”

But the hall fell silent as Trump turned to the tragedy in Parkland.

“This senseless act of mass murder has shocked our nation and broken our hearts,” Trump said as he recalled meeting with “great families, great people” who had lost loved ones.

Besides pitching his idea of arming “gun-adept” teachers, Trump also advocated for more aggressive screening of people for mental illness before allowing them to buy guns — a notion he also stressed at the news conference with Turnbull.

“We want to be very powerful on background checks,” Trump said. “When we’re dealing [with] the mentally ill, as we were in this last case — he was a very sick person and somebody that should have been nabbed.”

During the news conference, a reporter noted that Australia, in response to a string of violence, launched a sweeping gun buyback program in 1996 and has not experienced a mass shooting since. Turnbull was asked whether he urged Trump in an earlier meeting to consider a similar initiative.

Turnbull said that his predecessor in Australia had undertaken “some very big reforms” and relayed that semiautomatic weapons are essentially not available for purchase in his country. But he steered away from offering advice to Trump.

“It’s a completely different context historically, legally and so forth,” Turnbull said. “We are very satisfied with our laws . . . . But we certainly don’t presume to provide, you know, policy or political advice on that matter here.”

Trump agreed that the United States and Australia are “very different countries with very different sets of problems.”

But, he added: “I think we’re well on the way to solving that horrible problem that happens far too often in the United States.”

Trump also chided Peterson as Turnbull looked on, saying the day of the Parkland shooting “was not his finest moment, that I can tell you.”

Peterson broke with widely accepted police practices put in place after the Columbine High School massacre in 1999.

Instead of waiting for backup or specially trained teams to arrive, officers are trained to pursue and eliminate the threat as soon as possible in an attempt to save lives.

Some officers involved in active-shooting incidents have described the horror that they or other officers felt during such moments as they pursued armed gunmen, who may be wielding more firepower than the responding officers.

When a gunman opened fire inside Pulse nightclub in Orlando, an off-duty officer working at the club exchanged shots with him. But that officer realized he was outgunned, holding only a handgun while the gunman had a rifle, so the officer retreated, police later said.

Broward County Sheriff Scott Israel criticized Peterson for his inaction, saying that he should have “killed the killer.” Instead, Israel said, Peterson took up a position outside the school during the shooting and never went inside.

Peterson, who had been with the department for more than three decades, resigned Thursday after being suspended by Israel. Attempts to reach him were unsuccessful.

Mark Berman and Jenna Johnson contributed to this report.