(Nov-05-2016, 03:20 PM)SrirachaSauceLover Wrote: I use IDLE Python 3.5.2 running on Windows 7.Can give demo,can use IDLE but not a fan it at all

In IDLE file --> New file paste in code under,save it as chaos.py(in Python 3.5 folder).
# File: chaos.py # A simple program illustrating chaotic behavior. def main(): print("This program illustrates a chaotic function") inp = float(input("Enter a number between 0 and 1: ")) for i in range(10): inp = 3.9 * inp * (1 -inp) print(inp) if __name__ == '__main__': # Will now run as a script # But will not run when you import it(have to call main()) main()Close all(IDLE) then open:
File --> open chaos.py.
Run --> Run Module(F5)
Output:Python 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
This program illustrates a chaotic function
Enter a number between 0 and 1: .5
0.975
0.09506250000000008
0.33549992226562525
0.8694649252590003
0.44263310911310905
0.962165255336889
0.1419727793616139
0.4750843861996143
0.9725789275369049
0.1040097132674683
>>> #Now will import it an run the same
>>> import chaos
>>> main()
This program illustrates a chaotic function
Enter a number between 0 and 1: .5
0.975
0.09506250000000008
0.33549992226562525
0.8694649252590003
0.44263310911310905
0.962165255336889
0.1419727793616139
0.4750843861996143
0.9725789275369049
0.1040097132674683
>>>
Quote:If your using a tutorial that puts in eval() in from direct input of a user, and does not inform you of the security risks...get a new tutorial.It's now an old book 2003 i think,and yes he use eval() in a lot places(not just in input) as he should not have done.
Had to check,has a copy of the book as pdf
