David_Novo

3 years ago

Problem Set 1C and Practice Quiz 1
1-I wrote this code (
http://dpaste.com/hold/773969/
) for Problem Set 1C and it doesn't give the same results that are shown in the test cases. However it gives the same results that the solution's code does. Any idea what is wrong in both?
2-Shouldn't this code (
http://dpaste.com/hold/773970/
) print True twice? I printed x after the first and second loops and got 11.0 and 10.0. Can't understand why it prints False and True. Is it because 0.1 is not really 0.1 (it's a float)?
3- Does anyone have the answers for Practice Quiz 1?

Did someone adequately answer your number 2 question? The links are dead so I can't see what the script was, but I assume it was similar to this:
x = 10.0
for i in range(10):
x += 0.1
print x, i
print x
print x == 11.0
print x
for i in range(10):
x -= 0.1
print x, i
print x == 10.0
print x
I also don't understand why I get a False. The print x above and below line 6 both say 11.0. Any help would be appreciated...