Python troubles (classes, SUPER BASIC)

So I was messing around with python classes and I had trouble understanding it, this is what I came up with

class Forest:
    def temperature (self,temperature):
    def displayTemp (self):
        return self.temperature
    def saying(self):
        print "This soup is %s" % self.displayTemp  


first.temperature('too cold.')
third.temperature('too hot.')

temperature=input("1~10; How hot is the soup? ")

if (temperature<=3):
elif (temperature==4,5,6):

the goal was for it to ask a question like "1~10; How hot is the soup? " and then you put in a number (1-3 = too cold; 4-6 warm; 7-10 too hot) but instead of calling back the response it doesn't do anything.

I'm totally new to python and I have looked around but my lack of understanding makes it harder for me and I read a couple things here on what I thought it might be, but no luck.


Your code has several problems.

By itself first.saying is just a reference to the function object; you need parentheses to actually call it: first.saying(), second.saying(), etc. You need to do the same with self.displayTemp().

Also, int(temperature) doesn't change the value of temperature; it returns a new value that is converted to int. If you want to replace the old value, you need to do temperature = int(temperature).

Also temperature==4,5,6 won't do what you seem to want. You need to do something like 4 <= temperature <= 6.

You should read the Python tutorial to get familiar with the basics of Python.

Need Your Help

Make element fill horizontal line

html css3 alignment

This is a question similar to many that have been asked before. However, with all the previous questions, the necessary widths are known. For me, the widths are unknown.

How to query subdocument array using value in main document

arrays mongodb parameters mongodb-query aggregation-framework

I have a Document that has a few properties and one of the properties is an array of sub documents, I want to find documents and compare property in main document in to property in sub document arr...