A student who triggered an armed police response when he brandished a fake gun on a university campus has been jailed for eight months.

Yihe Xiong, 25, took the realistic-looking imitation Beretta pistol into a University of Exeter building where he was due to give a presentation.

He told students he had 12 bullets and claimed that if the presentation went badly he would open fire.

Part of the Streatham campus, the university’s largest site in Exeter, was evacuated and armed police were deployed.

Xiong, who was studying a master’s degree in computer studies, admitted possession of an imitation firearm with intent to cause fear of violence. He told Exeter crown court that it was a prank or joke.

But sentencing him to prison, Judge Peter Johnson said: “It was a calculated act of breathtaking stupidity.”

The judge said terrified students did not know if someone was about to go on a “killing spree” and praised police for their actions.

Johnson said: “You are academically gifted but socially awkward and did this to impress and be admired.”

He said there had been a number of incidents in schools and on campuses in other countries and he said he failed to understand how Xiong could have thought what he was doing was simply a joke.

The court was told Xiong was from a respectable family in China, where his father was a judge.

Herc Ashworth, prosecuting, said Xiong took the fake pistol into to the Amory building in June and was chatting to three other students when he produced the black handgun and waved it in the face of one of them.

Xiong said he had 12 bullets in the gun. He said: “If the presentation goes badly I am just going to open fire.” He said it was a real gun and pointed it at another student, calling him a target.

One of the students told a tutor, who called police. Officers quickly arrived at the Devon campus.

After he was arrested Xiong said he had been kidding and he had no grudge against his classmates.

Brian FitzHerbert, in mitigation, said the student had won a scholarship to study for a PhD in Canada and his parents had been left “utterly distraught”. The court was told he had been told to leave the university and his hopes of becoming a software developer had been ruined.

FitzHerbert said Xiong had not been motivated by malice or cruelty but had shown a lack of judgment, wrongly believing he was being “cool, daring and funny”.

He pleaded for a last chance for Xiong saying he had no previous convictions and was an “impeccable and immaculate” character.

At a previous hearing, his solicitor, Caroline Salvatore, said: “He is a Chinese ‘hooray Henry’. He is full of loud japes of dubious decision but absolutely no ill will.”