Feb-22-2018, 08:37 PM
Hello all.
New to forums.
1st, if there are any sticky posts that contain links to helpful resources, I'd love someone to post a link.
I'm working my way through code academy's python course and I'm stuck and don't want the answer given to me directly on their forums. This is the explanation from the code academy workspace:
Explanation:
An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not).
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.
This means that, for this lesson, you can't just test the input to see if it's of type int.
If the difference between a number and that same number rounded is greater than zero, what does that say about that particular number?
Problem:
Define a function is_int that takes a number x as an input.
Have it return True if the number is an integer (as defined above) and False otherwise.
And here is my code so far:
Can anyone point me in the right direction without directly giving me the answer?
Thanks and looking forward to getting to know people.
New to forums.
1st, if there are any sticky posts that contain links to helpful resources, I'd love someone to post a link.
I'm working my way through code academy's python course and I'm stuck and don't want the answer given to me directly on their forums. This is the explanation from the code academy workspace:
Explanation:
An integer is just a number without a decimal part (for instance, -17, 0, and 42 are all integers, but 98.6 is not).
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.
This means that, for this lesson, you can't just test the input to see if it's of type int.
If the difference between a number and that same number rounded is greater than zero, what does that say about that particular number?
Problem:
Define a function is_int that takes a number x as an input.
Have it return True if the number is an integer (as defined above) and False otherwise.
And here is my code so far:
def is_int(x): NEED HELP HERE return True else: return FalseI'm unsure what the explanation is looking for here. I understand that I should be looking to see if the number is 7.6 or 7.1 vs just 7.0 or 7, but I'm unsure which python capability I should be writing my if statement with.
Can anyone point me in the right direction without directly giving me the answer?
Thanks and looking forward to getting to know people.