A US high school has apologised after students were set maths homework that asked which family member had sexually assaulted an eight-year-old girl.

The assignment, focusing on Maya Angelou's autobiography I Know Why The Caged Bird Sings, also asks students a question about a single mother working as a pimp and a prostitute.

It provided an algebra formula that asked: "Angelou was sexually abused by her mother's ___ at age 8, which shaped her career choices and motivation for writing."

Pennridge High School students needed to solve the formula before deciding whether the answer was boyfriend, brother or father.

The next question asks: "Trying to support her son as a single mother, she worked as a pimp, prostitute and ___."

Another formula must be solved to determine if the answer was bookie, drug dealer or nightclub dancer.

Pennridge Superintendent Jacqueline Rattigan said the school had received complaints about the material, which was obtained from a website for teachers around the world to share resources.

"We apologise to anyone who was offended by the content of the assignment and have taken steps to avoid such occurrences in the future," Ms Rattigan said in a statement.

A similar homework assignment caused controversy in Fort Myers, Florida, in 2015.

In that case, a middle school teacher also downloaded the algebra homework from an external website.

The district said the veteran teacher did not carefully examine the homework and called it an oversight that would not be repeated.