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!
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

Brett Stephen
2,869 PointsWhich of the following is *not* a method of dir(float_a) where float_a = 1.2?
The possible answers were round, conjugate, as_integer_ratio and is_integer. All of which I think is correct, but maybe I'm wrong. Please clarify. This is one of the questions in the Python Quiz.
2 Answers

Andrew Molloy
37,259 PointsIt asks you to try it in Workspaces, if you do that you will get a list of methods. Notice that some are "built in" methods and have __ name (with underscores) instead of just 'name'. That's basically what it's asking you to distinguish. Which one is the built in one and not directly a method of dir(float). Only one of them is a built in method.

Marko Koron
20,658 PointsSince there are a lot of methods is hard to read the output so you can use the following trick dir(float_a.conjugate), dir(float_a.as_integer), ... You will see that one call wil give an error. In the end the correct answer was a method for which I was 100% sure that belonged to float :D.

Andrew Molloy
37,259 PointsI disagree as it wouldn't give you an error on the one that is built in compared to explicitly the float. I just tried now in the workspace and the correct answer and one of the incorrect answers gave identical results.

Marko Koron
20,658 PointsSorry, but are wrong on this one. :)

Brett Stephen
2,869 PointsI tried float.round() and got an error "AttributeError: 'float' object has no attribute 'round' ", whereas, float.is_integer() return false, float.as_integer_ratio() return (5404319552844595, 4503599627370496) and float.conjugate() return 1.2.
Brett Stephen
2,869 PointsBrett Stephen
2,869 PointsI did, but now I understand. Round is the answer. Thanks.
Madeleine Dougherty
355 PointsMadeleine Dougherty
355 PointsWhat is the difference between a built in method and any other method?
Andrew Molloy
37,259 PointsAndrew Molloy
37,259 PointsI believe they're the ones that are built into the Python language/interpreter itself and so available across the language to use with any class. As opposed to methods only available on certain classes. Or methods you've created yourself.