[Tutor] first steps
ryan at quantodesign.com
Wed Mar 16 02:26:16 CET 2011
I'm a newbie running my very first module . . .
Mac OSX 10.6.6
IDLE v 3.2
Tk v 8.5
I saved this module to my desktop
> # File: chaos.py
> # A simple program illustrating chaotic behavior.
> 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)
When I open and run this module in IDLE's shell the application hangs. This can sometimes be 'fixed' by going to Run > Check Module and then running the module. But I have a feeling I'm doing something wrong. Is there a better way to import the file into IDLE so I can run it without crashing the app?
Also, when it works correctly, IDLE won't run the program again via the >>> chaos.main() statement. I get this:
> Traceback (most recent call last):
> File "<pyshell#1>", line 1, in <module>
> NameError: name 'chaos' is not defined
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor