Python OOP - object has no attribute

Posted by user1744269 on Stack Overflow See other posts from Stack Overflow or by user1744269
Published on 2012-10-14T03:24:10Z Indexed on 2012/10/14 3:37 UTC
Read the original article Hit count: 112

Filed under:
|
|
|

I am attempting to learn how to program. I really do want to learn how to program; I love the building and design aspect of it. However, in Java and Python, I have tried and failed with programs as they pertain to objects, classes, methods.. I am trying to develop some code for a program, but im stumped. I know this is a simple error. However I am lost! I am hoping someone can guide me to a working program, but also help me learn (criticism is not only expected, but APPRECIATED).

class Converter:

    def cTOf(self, numFrom):
        numFrom = self.numFrom
        numTo = (self.numFrom * (9/5)) + 32
        print (str(numTo) + ' degrees Farenheit')
        return numTo

    def fTOc(self, numFrom):
        numFrom = self.numFrom
        numTo = ((numFrom - 32) * (5/9))
        return numTo

convert = Converter()

numFrom = (float(input('Enter a number to convert..                '))) 
unitFrom = input('What unit would you like to convert from.. ')
unitTo = input('What unit would you like to convert to..    ')

if unitFrom == ('celcius'):
    convert.cTOf(numFrom)
    print(numTo)
    input('Please hit enter..')


if unitFrom == ('farenheit'):
    convert.fTOc(numFrom)
    print(numTo)
    input('Please hit enter..')

© Stack Overflow or respective owner

Related posts about python

Related posts about class