In python if I divide 6/3 I get 2, that's fine. But I divide 6/4 and get 1...

Why aren't I getting a decimal? I would like to know because I want to make something that can detect wether or not a number is whole. (I need help with that too). But I thought I would give it a shot myself and found that it wont give me a decimal when it should.

In python if I divide 6/3 I get 2, that's fine. But I divide 6/4 and get 1...

Why aren't I getting a decimal? I would like to know because I want to make something that can detect wether or not a number is whole. (I need help with that too). But I thought I would give it a shot myself and found that it wont give me a decimal when it should.

Thanks

Here is one way to do this:

a = 6
b = 4
# assure a float division
print a/float(b) # 1.5
# test for integer (whole number)
print type(a) == int # True

Thanks guys this helps alot, the only thing now though, is that if I have, let's say, 2.0, both of those suggested things return false (unless I'm using them wrong)

I need to find the prescense of a whole number, not if a decimal is there or not. Is there a way to do that?

Thanks guys this helps alot, the only thing now though, is that if I have, let's say, 2.0, both of those suggested things return false (unless I'm using them wrong)

I need to find the prescense of a whole number, not if a decimal is there or not. Is there a way to do that?

Do you want to include decimals like 2.0 , 2.00000 etc as a whole number ??