Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Python OOP Quiz Question

Not understanding why this is "False" (according to the quiz). I believe it to be True that Orange().squeeze() will return True.

class Orange(Fruit):
    has_pulp = True

    def squeeze(self):
        return has_pulp

Orange().squeeze() will return True.

True or False?

Quiz Answer: False

2 Answers

Steven Parker
Steven Parker
243,266 Points

The answer to the question is false — not because the method would return "False", but because you don't know from this code what it would return.

That's because the "has_pulp" being returned here is not the class variable (that would be "self.‍has_pulp"), but a global that may or may not be defined (and may or may not have a value of "True").

From what I could tell from doing a search, is the answer "False" because "Orange().squeeze()" as written is not passing an argument for the squeeze method, and therefore would return a boolean value of "False"?

I guess for the explanation of essentially, "it's false because we don't have enough information to say it will be True", that says to me that it's not a well crafted question in my opinion...if I am following your explanation.

It's like asking if "There are Aliens" is True/False...since there's only 2 options (True/False), why would it necessarily be False just because there's no way of establishing it's True (as there is just as much information available to be unable to establish that it is False)?

Steven Parker
Steven Parker
243,266 Points

It would be similar if the question was "What is the result of calling Orange().squeeze()?", but what was actually asked was "Orange().squeeze() will return True.". I agree it's potentially confusing. You might want to shoot a suggestion to the staff as described on the Support page.

I also got stuck on this and put it into the editor to try and better understand. obviously it fails because the Fruit class is inheriting from nowhere but I didn't recognize this syntax and ran this the best way I knew how always getting "True"- this seems like a trick question that doesn't have a lot of educational benefit.

Steven Parker
Steven Parker
243,266 Points

You might want to also send in a suggestion to the staff. More requests might help to get it improved.