2011/6/13 amt <0101...@gmail.com> > I came up with: > print "Roosters", 100 - float(25) * 3 % 4 > > This is for line 3 so it is more precised. Is it correct what I did?
I don't think so. All the operations in this line are for integers. % means the remainder of the division, so according to the precedence, the original may be parenthesed as 100-(25*3%4), which is really 97 (75 divided by 4 is 18, and 3 remains). > What do I have to do for line 5? > Hard to say without you share your Python version with us. Division behaves differently in P2.x and P3.x Also note that besides float() there is a more simple way to make a float from an integer: write 1.0 instead of 1, and it becomes a float as well as the result of the operation. Using the function is good if you work with a variable.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor