Need to indent the function block
def main():
print("This program illustrates a chaotic function")
x = eval(input("Enter a number between 0 and 1: "))
for i in range(10):
x = 3.9 * x * (1 - x)
print(x)
main()
Also, instead of eval
I would just use float
:
def main():
print("This program illustrates a chaotic function")
x = float(input("Enter a number between 0 and 1: "))
for i in range(10):
x = 3.9 * x * (1 - x)
print(x)
main()
Sample:
>>> def main():
... print("This program illustrates a chaotic function")
... x = float(input("Enter a number between 0 and 1: "))
... for i in range(10):
... x = 3.9 * x * (1 - x)
... print(x)
...
>>> main()
This program illustrates a chaotic function
Enter a number between 0 and 1: .2
0.624
0.9150336
0.303213732397
0.823973143043
0.565661470088
0.958185428249
0.156257842027
0.514181182445
0.974215686851
0.0979659811419