"I" means the same as "in" in English, while "på" means "on", when it comes to locations.
Jakken henger i skapet - The jacket hangs in the closet
Jeg er i klasserommet - I am in the class room
Han er på fjellet - He is on the mountain
Hun er på taket - She is on the roof
Teppet på gulvet - The carpet on the floor
"I" is also used when "surrounded" by something. In bed or in government are examples of this:
Han ligger i senga - He lies in bed
Hun jobber i kommunen - She works in the municipality
In the bed example, you could also write "Han ligger på senga", but that would indicate that he lies "on top of the bed", and not "in bed".
"På" is also used for things that are attached to something:
Flue på veggen - Fly on the wall
Blad på treet - Leaf on the tree
Both "på" and "i" can be used for geographical locations. When talking about whether you are "i" a place or "på" a place, the usage varies, but it's more often "på" if it's an island or mountain, and "i" if it's not. These are local variations and historical reasons for why this is so, like if people used to travel there a certain way the preposition might indicate that. That also goes for "down in town" or "up in town".
"På" and "i" could also be used for smaller locations, like "på kjøkkenet" (in the kitchen), "på badet" (in the bathroom) and "i stua" (in the living room). This does not follow the same "rules" laid out earlier, but generally speaking "på" is more specific than "i" in these circumstances.