15/100 is 0?


#1

Maybe explain in the lesson/hint how division works instead of just saying "It looks like tip is set to 0 intead of 0.15" and "use 15.0". I.e. explaining a bit about int and float

Btw, instead is misspelled.


#2

When dividing, do the number of significant figures of both the denominator and numerator have to be equal?


#3

Nope, it's just in python 2.7.* which codeacdemy is using when you use the / it does non-float division by default. There are several ways to get float division though.

a = 5 // 10
a = float(5) / 10
a = 5.0 / 10
a = float(5 / 10)

EDIT:

In python 3.* the / defaults to float division and you have to use // to get not float division or surround it with int()


#4

Got it. Thank you for the thorough explanation!


#5

Same problem, thanks for the solution but I'm not english speaker so I don't understand what "float division" means, some help?


#6

Float is a number with a decimal point like "15.0". Integer is a number without it like "15". I suppose computers differentiate between them and behave differently. e.g. if you divide 15 with 100 it would be less than "1", so according to the computer, the solution is "0" rather than 0.15 as you used an integer, a whole number. In a similar manner, if you divide 15 with 14, the solution is "1" rather than "1.07142857143". So float division is a division where a float number is used. To make a number float, you can just add a ".0" after the whole number. So "1.07142857143", "15.0" "0.15" are all float numbers. I hope this answer is helpful and not confusing.


#7

It is a great explanation! Thank you so much!!


#8

Great explanation indeed. Thanks as well.


#9

You are welcome! :smile: Glad I could help.


#10

I was just about to post a topic on this.
As the others have said, it was indeed an excellent explanation.

Thank you!


#11

Great explanation!! Thanks!!


#12

Got it! Thanks a lot!


#13

It is a great explanation. Thank you