Converting voltage reading from temperature sensor into Celcius
Typically for electronic components, there is a datasheet available which explains most of the stuff you need to know.

The TMP36 isn't different in that regard. So the datasheet is published by 
Analog Devices.

In it you will fine important ratings like which supply voltage range the device is made for (2.7V - 5.5V).

And of course there is a specification on the behavior of the temperature sensor.

Table 4 on page 8 gives us the values you find in your code:


  Offset voltage: 0.5V and Output scaling: 10mV/°C


Which is what you are calculating.

Every sensor will be different and every will come with it's own specification. There are temperature sensors around with a digital interface, so you might have to do no conversion at all or have to calculate a strange polynomial function to get to the temperature.

I think the tutorial is a bit lacking in not telling you that there is a datasheet available. Datasheets are one of the most important things for engineers.

More complex devices (like a microcontroller) often come with a reference manual which covers the same stuff for all devices of a family and then there is a datasheet for each of the devices (or small family of devices).