> > > Can you explain your reasoning? Why do you think line 3 needs > to be changed? Why line 5?
Well the exercise says: "Rewrite ex3.py to use floating point numbers so it’s more accurate (hint: 20.0 is floating point)." I am honestly confused. I have read the exercise and found three lines that could use the floating point(2,3 and line 5). This is were the confusion is appearing. I can understand why at line 5 I use floating point. 6,75 is more precise than saying 7. But I can't understand at line 2 and 3. I mean it makes no difference for me. Saying 30 or 30.0 is the same thing. As well as saying 97 or 97.0. > > I came up with: >> print "Roosters", 100 - float(25) * 3 % 4 >> >> This is for line 3 so it is more precised. >> > > In what way do you think this is more precise? > As I said, I am confused when it comes to line 2 and 3. But I think having more digits after the " ." makes it more precise. > > I don't understand your comment on line 5. > Why would the answer be 6.83? > Can you add parentheses to the expression > showing how you arrive at 6.83? > The answer at line 5 is 7 because I have integers and I think Python approximates. I have done line 5 with pencil and paper: 3 + 2 + 1 - 5 = 1, 1 + 4%2 = 1, 1 - (1/4)= 1, 1 + 6 = 7 If I use floating point the right answer will be 6,75 but I don't know how to get to this answer. On paper I got 7 not 6,75. I'm horrible at math right now, so please forgive me. > HTH, > > -- > Alan Gauld > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > > > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > http://mail.python.org/mailman/listinfo/tutor > Thanks for helping me out!
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor