The temperature can be read directly from a sensor on the RPi, in this file:
# cat /sys/class/thermal/thermal_zone0/temp
50306
As you can see it comes in milli-degrees Celsius. Use awk to convert it to degrees:
# awk '{print $1/1000 " C"}' /sys/class/thermal/thermal_zone0/temp
50.843 C