Do you want the long or the short answer? ;-) The short answer is “not very well” but you can make an O.K. substitute for one of them.
Baking powder: To make 1 teaspoon of baking powder use ¼ teaspoon baking soda, ½ teaspoon cream of tartar and ¼ teaspoon of cornstarch. If you don’t have cream of tartar then double the cornstarch. It’s not perfect, it is not double acting, but it will work.
Baking soda: Substituting baking powder for baking soda is not recommended. However, there is information that you can replace ½ teaspoon of soda with 2 teaspoons of baking powder AND replace the acidic liquid (such as buttermilk) with a non-acidic liquid. Success may be very limited and flavors will be changed.
The entire subject is quite scientific and has to do with acid and alkaline foods and some other components. I think the folks over at Serious Eats did a good job of explaining the difference. Check them out if you want to learn more.