Hi All
Could you please help me with the following,

#Convert C to F
def Tc_to_Tf ():
Tc = input ("What is the Celsius Temperature ? " )
Tf = 9.0/5.0 * Tc + 32
print 'The temperature is ', Tf, ' Degrees Fahrenheit'

I get NameError: name 'Tf' is not defined
I dont understand as Tf is defined as a formulae?
Thanks in anticipation
Graham
Ps, dont think I have these tags right, some help here too please

#! /usr/bin/python
#Convert C to F
def Tc_to_Tf():
Tc = input ("What is the Celsius Temperature ? " )
Tf = 9.0/5.0 * Tc + 32
print 'The temperature is ', Tf, ' Degrees Fahrenheit'
Tc_to_Tf()

Like gerard4143 says, you have to make the print statement part of the function, since Tf is local to the function. The other option would be to return Tf to make it available outside the function:

#Convert C to F
def Tc_to_Tf ():
Tc = input ("What is the Celsius Temperature ? " )
Tf = 9.0/5.0 * Tc + 32
return Tf
Tf = Tc_to_Tf ()
print 'The temperature is ', Tf, ' Degrees Fahrenheit'

Please use the [code=python] and
[/code] tag pair to enclose your python code.

Alternatively you can use placeholder (same Snee's example)

#Convert C to F
def Tc_to_Tf ():
Tc = input ("What is the Celsius Temperature ? " )
Tf = 9.0/5.0 * Tc + 32
return Tf
Tf = Tc_to_Tf ()
#.2f instructs Python that placeholder holds float number with 2decimal places. try 3f, 4f etc and see how it does
print 'The temperature is %.2f Degrees Fahrenheit' %(Tf, )

Hi Guys
Thanks very much for your post.
I understand now that I have to make Tf part of the function and how to do so.
I dont understand your Tf=Tc_toTf () command, could you please explain how it works.

Hi Guys
Thanks very much for your post.
I understand now that I have to make Tf part of the function and how to do so.
I dont understand your Tf=Tc_toTf () command, could you please explain how it works.

Many thanks
Graham

It simply means that function Tc_toTf() returns a value that you want to put into variable TF.

Dear Friends,
I developed Desktop application in C# .Net for client. client purchased software and installed it one than more system without my permission. How to restict him to not ...