I am beginning to learn python. I wrote the following module file to be imported into python, but the output in IDLE does not show anything. Please help
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()
I used
import chaos
command to import the module, but it doesn't show any output.
ForceBru
45.1k10 gold badges72 silver badges104 bronze badges
2 Answers 2
-------chaos.py----------
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)
-------fileimport.py---------
import chaos
chaos.main()
Note Both these files should be in same directory
Parent Folder
|
|----chaos.py
|----fileimport.py
answered Dec 17, 2015 at 6:49
Prashant Shukla
7623 gold badges6 silver badges20 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
chaos.py(starting with lowercase and ending with.py?) Have you put it into the correct directory?