3/15 Practice makes perfect. Concept?


I’m not even sure where to start with this one. I’ve been having massive troubles through this entire section. So I came back to try and get through them one by one without cheating. I don’t understand what I have to do to find out something is an integer. If somebody could elaborate on the idea behind this lesson without actually showing me the actual code I’d really appreciate it. Trying to figure out how to come to the right conclusion on my own. Thanks in advance.


exercise url:


so we can quickly access the lesson.

the exercise is explained quickly here:

For the purpose of this lesson, we’ll also say that a number with a decimal part that is all 0s is also an integer, such as 7.0.

normally, 7.0 is a float.

How would you go about this?

We could get the integer value of the number passed into the function. How does this help us?


How do I go about copying my code that im working on onto the thread here?


you can simple copy all your code from the lesson, and paste it here on the forum.



I’m not sure why this works. I don’t understand why x - round(x) > 0 determines integer’ness’. I have a feeling that I’m just overthinking the whole thing.


you do understand what integers are? Just to be sure

lets do two examples:


write for me how the if condition looks for these two numbers after they are being processed by round()


So basically the presence of the decimal point (excluding zero) makes it so that the number rounds to a different whole creating a value of more than zero as the difference. So the program can then determine if there’s anything other than zero in the decimal place…7.0 being an integer and 7.6 not. But if my two values were 7.0 and let’s say 7.4 wouldn’t the 7.4 round down to 7 giving me a zero result with something that’s not an integer. Causing it to not work?


yes, round(7.6) would give 0.6, which is greater then 0

there seems to be nothing wrong with your understanding, i barely did anything and you got to the right solution :slight_smile:

maybe round() is not the best approach, are there other functions we learned? Which do not round, but rather just floor (discarding the digits?)


So the round function doesn’t round the number to the whole it just isolates the decimal from?


seems i was a bit too hasty :wink: round() is not the best function to use, but your way of thinking is correct :slight_smile: we just need a slightly better function then round


Are you talking about the floor division //. I tried to read the description of how that works and thought my head was going to implode :crazy_face: but like I said I might be overthinking it.


floor division is simple, after the division the number is rounded down to the nearest integer, always, even when the decimal value is something like .6 or .7

no, i was talking about a function which can get the integer value of a float number. You learned two functions so far which should be able to do this.

floor division is possible, by dividing by 1 you will get the integer value


which were you referring to, the only other thing that comes to mind is int() but the instructions for this lesson asked that I not use that. Just for my own clarification, what exactly does the round() function do? Does it round up and down or simply isolate the decimal remainder


no? The lesson says:

This means that, for this lesson, you can’t just test the input to see if it’s of type int

so just doing type(x) == int isn’t sufficient, it doesn’t mean we are not allowed to use int()

you also learned abs()

thankfully, there is python documentation for it:



Upon seeing the exercise, you’re meant to think about which operations turn out different for integer and non-integer numbers – they have different mathematical properties, and where they differ, it’s possible to tell whether it’s whole or not. Rounding, ceiling, flooring, floor division come to mind. You could also subtract numbers while it’s still positive and count how much is subtracted (ideally subtracting more and more so that even large numbers get processed quickly, doubling the number each time is a good strategy)
I expect there are more ways to do it than that.
String conversion is worth mentioning, looking at what happens past the decimal point. I don’t like that though, because it could be less accurate (some non-ints could probably get displayed with .0)

For most of these problems you should to some degree forget all about python and think about how you yourself would carry them out, and study what you do.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.