I am interested in learning python and picked up a friends textbook to try and work through it. I have no cs experience so am pretty clueless. I am having difficulty with one of the problems in the first chapter lol. i am trying to make the program spit out a loop of 8 numbers based on a simple algorithm. Here is the code:
def main():
print "This program illustrates a chaotic function."
print "Please enter two numbers between 0 and 1."
x = input ("Enter first number: ")
y = input ("Enter second number: ")
print
print "input", x, y
print "-----------------"
for i in range (8):
x = 3.9 * x * (1 - x)
for i in range(8):
y = 3.9 * y * (1 - y)
print x, y
main()
output:
This program illustrates a chaotic function.
Please enter two numbers between 0 and 1.
Enter first number: .25
Enter second number: .25
input 0.25 0.25
-----------------
0.540417912062 0.73125
0.540417912062 0.76644140625
0.540417912062 0.698135010439
0.540417912062 0.82189581879
0.540417912062 0.570894019197
0.540417912062 0.955398748364
0.540417912062 0.166186721954
0.540417912062 0.540417912062
>>>
the first loop is only spitting out the last calculation repeatedly whereas the second is computing correctly so im a bit confused... any help would be appreciated
thanks