Why we need to we divide 15.0 by 100, not 15 by 100?


Replace this line with your code. Do not remove the backticks that are above or below this line.


Please, explain what you are trying to ask, and give an example.

Right now I don't understand the conditions you are asking this question under.


I wonder what he wonders too, in assignment 5 on Tip calculator you cant divite 15 by 100
you have to divide by 15.0



@mrfatdog21: That's because you want a float value after you divide something.
In coding, whenever we divide two integer numbers, we get an integer number as a result.
But in case one of the numbers is a float, or the expression has a float value as a result, you'll get a float value as a result.

Got it? No? Okay, here's an example:

print (1/2) #brings you zero
print (1.0/2) #brings you zero point five
print (1/2.0) #brings you zero point five as well

Hope this helps :slight_smile:


That's not the case for python. In python 5/2 should give 2.5 and 5//2 should give 2. I could be wrong, but I don't think so.


Depends on the version of Python you use.

5/2 should equal 2 in the Codecademy Python course(Python 2.7 I think), but 2.5 in Python 3.


@tagrunner23016, maybe you should check what you think, because that isn't the case.


Just like @cadecodes mentioned, you're not correct.
Regardless if is Python 2.x.x, 3.x.x, 4.x.x or anything else, a divison between a float number with another float number, or integer number, you'll get a float value as a result.

Note: considering you are using /.

The difference between / and // is that the first one is the actual division where the second one is what we call as "floor division" which means:

print (1.0//2) # 0 (check the floor definition in mathematics)
print (1.0/2) #0.5

Such feature is available in Python 3.x.x, some say it's available in Python 2.2.x but not sure about this info.

Note: doing this operation in Python 2, which will be the same in both cases where the final result will be equal to 0.5