(Nov-05-2016, 08:39 PM)Barrowman Wrote: All you do is delete the spaces in front of the text. In your code you had
main()
which has 8 spaces in front of it. Just delete them
Can also delete main() all together,dos not need that call when import it.
# 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)
Test import:
Output:
>>> import chaos
>>> 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
Look a little at at
if __name__ == '__main__': and what it does.