Hello, I am a python beginner currently learning from "Learn python the hard way". I'm stuck at exercise 3 and I would like if it's possible to get some help so I can move on.<br>Here is the source code:<br>
<br>1 print "I will now count my chickens:" <br>2 print "Hens", 25 + 30 /6 <br>3 print "Roosters", 100 - 25 * 3 % 4 #Output is 97<br>4 print "Now I will count the eggs:" <br>5 print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #Output needs to be 6,83 but Python give me 7<br>
6 print "Is it true that 3 + 2 < 5 - 7? " <br>7 print 3 + 2 < 5 - 7 <br>8 print "What is 3 + 2?", 3 + 2 <br>9 print "What is 5 - 7?", 5-7 <br>10 print "Oh, that's why it's False."<br>
11 print "How about some more. " <br>12 print "Is it greater?", 5 > -2 <br>13 print "Is it greater or equal?", 5 >= -2 <br>14 print "Is it less or equal?", 5 <= -2 <br><br>
The author says " Notice the math seems “wrong”? There are no fractions, only whole numbers. Find out why by researching what a “floating point” number is." <br>I have to rewrite it to use floating point numbers so it's more accurate. I have read the lines of code and only line 3 and 5 needs to be changed. <br>
<br>I came up with: <br>print "Roosters", 100 - float(25) * 3 % 4 <br><br>This is for line 3 so it is more precised. Is it correct what I did? What do I have to do for line 5?<br><br><br><br><br><br><br><br>Thanks in advance!<br>
<br><br>Regards, <br>amt.<br>