"""
Write a function to convert temperature from Celsius to Fahrenheit scale.
oC to oF Conversion: Multipy by 9, then divide by 5, then add 32.

Examples

>>> Cel2Fah(28.0)
'82.40'
>>> Cel2Fah(0.00)
'32.00'
"""
so it says, but i couldn't think of an a way to do so efficiently. But none the less, i felt i should try it and then look up a better way after
the code i wrote is as follows;

def Cel2Fah(temp):
	Fah = temp * 9 / 5 + 32
	Fah = float(Fah)
	Fah_string = str(Fah)
        a = Fah_string.split('.')
        b = a[1][0:2]
        if len(b) < 2:
        	b = b + '0'
        elif len(b) > 2:
        	b = float(b)
        	b = round(b)
        	b = str(b)
                b = b[0:2]
        c = a[0]
        f = str(c) + '.' + str(b)
        return f

could someone show be a better way? it would be much appreciated. i have spent a lot of time reading documentation, but when i go to put it into practice its messy like this ( most of the time), please help me advance my knowledge.

def Cel2Fah(temp):
	Fah = temp * 9. / 5 + 32
	Fah_str = '%.2f' % Fah
	return Fah_str
def Cel2Fah(celcius):
	return '%.2f' % (celcius * 9. / 5 + 32)
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.