Most authorities will state that the Chinese invented gunpowder. It has always been a bit difficult to know who invented things (a bit less so since the introduction of patents and the like, but even to this day, inventors find themselves arguing the point) and this is further complicated by the tendency of myth and legend to enter history as fact. It might just have easily been another civilization that was trading with the Chinese that introduced the substance to China.

More importantly, without a gun, one does not have "gunpowder" and China may (or may not) have invented the first gun (tightly wound bamboo barrels). But the Chinese are widely (again perhaps by more myth and legend than fact) believed to have failed to make the connection of the explosive powers of the substance and the substance's suitability as a propellant.

The use of gunpowder as a propellant is widely thought to have been a European development. Western history tends to show a bias towards the west, so I would not be too quick to discount the possibility (if not probability) that the Chinese or Arabs having had the greatest access to the substance actually made first use of gunpowder (propellant).

So, the substance known as gunpowder became such only when humans realized the suitability of the substance as a propellant for a projectile (the earliest such by many accounts were arrows and stones). As with many early (and even current day inventions) this was most likely an evolutionary process and who and where this happened will likely remain a mystery. But the answer that will get your child an "A" on the history test is: "the Chinese invented gunpowder."