I already learnt that we use much and many in negative and interrogative sentences and a lot of in affirmative sentences. But I saw this example in the book and I don't know if it's correct. Can I answer: there are a lot of bananas. Or can I answer with the word in the question. For example: How many books are there? There are many/ There are a lot. Please help me understand.
There are many.
The sentence is grammatical. We usually use "many" in interrogative and negative statements. Its use in affirmative statements as above is slightly formal. In informal English, we use "a lot" or "lots" as follows:
There are a lot/lots.
Many, a lot, and lots are pronouns in the above sentences. As determiners, we say a lot of, lots of, or many as follows:
There are many bananas/there are a lot of bananas/there are lots of bananas.
As the word "bananas" is already is the question, it's better not to use it again in the answer. "Many" as a pronoun in the reply "there are many" means "many bananas".