Aug-23-2023, 11:56 AM
Hi @dbrown8978 ,
I think you found out by now how to print the chaotic numbers side by side, and learned why you should not use "eval()".
But now for something completely different. The task was to write a "chaos()" function, but you did not do so. You wrote a "main()" function which was not used as a function, instead it did all the work.
I think you should have created a "chaos()" function like this:
I think you found out by now how to print the chaotic numbers side by side, and learned why you should not use "eval()".
But now for something completely different. The task was to write a "chaos()" function, but you did not do so. You wrote a "main()" function which was not used as a function, instead it did all the work.
I think you should have created a "chaos()" function like this:
print("This program illustrates a chaotic function") def chaos(base, anumber): """ This is a function which mixes together some numbers to produce another. """ return base * anumber * (1 - anumber) numberofrows = int(input("how many rows should I print? ")) x = float(input("Enter a number between 0 and 1: ")) y = float(input("Enter a number between 0 and 1: ")) for i in range(numberofrows): x = chaos(2.9, x) y = chaos(3.9, y) print(f"{x:<20} {y:<20}")
Output:This program illustrates a chaotic function
how many rows should I print? 6
Enter a number between 0 and 1: .2
Enter a number between 0 and 1: .3
0.46399999999999997 0.819
0.7212416 0.5781321000000001
0.583051247845376 0.951191962303401
0.7049972216708452 0.18106067129594494
0.6031308034109796 0.5782830479626462
0.694155708424637 0.9510998811665442