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.
Here is the source code:

1 print "I will now count my chickens:"
2 print "Hens", 25 + 30 /6
3 print "Roosters", 100 - 25 * 3 % 4 #Output is 97
4 print "Now I will count the eggs:"
5 print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 #Output needs to be 6,83 but
Python give me 7
6 print "Is it true that 3 + 2 < 5 - 7? "
7 print 3 + 2 < 5 - 7
8 print "What is 3 + 2?", 3 + 2
9 print "What is 5 - 7?", 5-7
10 print "Oh, that's why it's False."
11 print "How about some more. "
12 print "Is it greater?", 5 > -2
13 print "Is it greater or equal?", 5 >= -2
14 print "Is it less or equal?", 5 <= -2

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."
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.

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? What do
I have to do for line 5?







Thanks in advance!


Regards,
amt.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to