why no result from temprature function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dragrid
    New Member
    • Jan 2009
    • 29

    why no result from temprature function

    Hi
    Appreciate any help - why not getting any result from either print statement for celcius of farenheit

    Code:
    import re
    import os
    import string
    import sys
    
    def tempconvert():
        c = ""
        f = "" 
    
        print 'this program converts celcius to farenheit and visa versa'
    
        temp = raw_input ("enter f if you want Faren or c if you want celcius")
        degree = float(raw_input("enter temprature"))
    
        if temp == f:
            c = (degree - 32)* 5/9
            print 'the temprature in celcius is %d'  %c
        elif temp == c:
            f = (9/5 * degree) + 32
            print 'the temprature in farenheit is %d' %f
        else:
            print 'if you see this , good , there is no error'
    
    tempconvert()
    Thanks
    Last edited by bvdet; Jan 24 '10, 02:40 PM. Reason: Add code tags
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    Please use code tags when posting code. See "How to ask a question" in Posting Guidelines. This is not your first post. You should know this by now.

    BV - Moderator

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      Your problem is that you are comparing variable temp to an empty string.

      Code:
      def tempconvert():
          c = ""
          f = ""
      should be
      Code:
      def tempconvert():
          c = "c"
          f = "f"

      Comment

      Working...