0

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.

3
  • 2
    Is this file called exactly chaos.py (starting with lowercase and ending with .py?) Have you put it into the correct directory? Commented Dec 17, 2015 at 6:25
  • Also your indentation is off, please correct it Commented Dec 17, 2015 at 6:26
  • you can also paste an image in the question. Commented Dec 17, 2015 at 6:35

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

Comments

0

Main.py

import chaos
print(chaos.hello())

chaos.py

def hello():
   return "hello"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.