Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Importing a module
#11
(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 Wink 

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 Snooty
Reply


Messages In This Thread
Importing a module - by SrirachaSauceLover - Nov-05-2016, 03:20 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 03:37 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 03:53 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 03:59 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 04:30 PM
RE: Importing a module - by Larz60+ - Nov-05-2016, 04:29 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 06:14 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 06:51 PM
RE: Importing a module - by nilamo - Nov-05-2016, 06:18 PM
RE: Importing a module - by metulburr - Nov-05-2016, 07:13 PM
RE: Importing a module - by snippsat - Nov-05-2016, 07:49 PM
RE: Importing a module - by Barrowman - Nov-05-2016, 08:39 PM
RE: Importing a module - by SrirachaSauceLover - Nov-05-2016, 09:17 PM
RE: Importing a module - by Barrowman - Nov-06-2016, 10:20 AM
RE: Importing a module - by snippsat - Nov-05-2016, 09:22 PM
RE: Importing a module - by Larz60+ - Nov-05-2016, 10:20 PM
RE: Importing a module - by SrirachaSauceLover - Nov-06-2016, 08:10 AM
RE: Importing a module - by nilamo - Nov-07-2016, 04:21 PM
RE: Importing a module - by metulburr - Nov-06-2016, 08:15 AM
RE: Importing a module - by SrirachaSauceLover - Nov-08-2016, 11:23 AM
RE: Importing a module - by snippsat - Nov-08-2016, 03:05 PM
RE: Importing a module - by ngltm - Jun-13-2018, 02:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  importing variables from module 8376459 1 313 Feb-18-2024, 02:24 PM
Last Post: deanhystad
  no module named 'docx' when importing docx MaartenRo 1 1,000 Dec-31-2023, 11:21 AM
Last Post: deanhystad
  My code displays too much output when importing class from a module lil_e 4 1,211 Oct-22-2022, 12:56 AM
Last Post: Larz60+
  Importing module in jupyter Noteboook ajitnayak1987 0 1,774 Jun-04-2021, 12:26 PM
Last Post: ajitnayak1987
  ERROR: importing desired module mbgamer28 0 1,704 Apr-05-2021, 07:46 PM
Last Post: mbgamer28
  importing module - not working jdhamblett 3 3,072 Jun-22-2020, 07:33 PM
Last Post: jdhamblett
  importing same python library in multiple custom module escape_freedom13 6 3,890 May-10-2020, 07:01 PM
Last Post: escape_freedom13
  Importing module from a package results in import error goghvv 2 2,436 Mar-27-2020, 07:13 PM
Last Post: goghvv
  Please help: problem installing/importing langdetect module in Jupyter Notebook ledgreve 3 7,367 Dec-30-2019, 08:17 AM
Last Post: LeanbridgeTech
  Problem with importing and using collections module pythomdummy 3 5,898 Nov-14-2019, 08:48 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020