A US maths professor has received praise after images of him looking after a student's baby during class went viral on social media.

Baby Assata was brought to the lesson by her father, Wayne Hayer, who had been unable to find a babysitter.

After explaining his situation, Professor Nathan Alexander held the child for his whole 50-minute class so Mr Hayer could "take good notes."

"I don't have children of my own," Mr Alexander told Buzzfeed News.

"I was worried that she would start crying but it actually went perfectly. She was extremely well behaved."

Professor Alexander teaches at Morehouse, an all-male, historically black liberal arts college in Atlanta, Georgia.

One of the school's most famous graduates was civil rights activist Dr Martin Luther King Jr.

Mr Alexander, 34, reportedly told Mr Hayer that he could bring his daughter to class after noticing that he often had to leave early to look after her.

"He works two jobs, is a full time student, is involved in leadership programmes at school and is a parent," Mr Alexander said in an interview with CNN.

"This photo serves as a reminder of what parents have to do every day and how important it is to have affordable childcare."

Speaking to Buzzfeed News, he said he bounced the baby girl up and down during the class and joked about sending her to sleep with his teaching.

"When she started falling asleep, I told the class 'I guess I'm being boring right now'," Mr Alexander said.

The picture was widely shared on social media with an outpouring of support for Mr Alexander and his teaching skills.

Social media users also praised Assata's father.

Other professors have also offered to help their students with childcare.

In a Facebook post, Assata's mother, Firda Hayer, expressed her thanks to Mr Alexander and to other social media users for their encouragement.

Mr Alexander said in a Tweet that he "appreciate[d] the love," but told the Atlanta Journal-Constitution newspaper: "I'm not an exception. Teachers do this in their own way every day."