very very basic question

Discussion in 'Python' started by aghazalp, Apr 2, 2006.

  1. aghazalp

    aghazalp Guest

    hi guys,
    this would be the most basic question ever...I am not a programmer but
    I am trying to learn programming in python...I was reading John Zelle's
    text book and instructed me to make .py file and save it on the desk
    top...then it said close the python GUI and double click on the icon of
    the I just made and that should run the program...well, the good news
    is that it does but when I input a number for calculation and press the
    enter key the program closes...Does any one know what the problem is?

    thanx a bunch
    andy
    aghazalp, Apr 2, 2006
    #1
    1. Advertising

  2. aghazalp

    Georg Brandl Guest

    aghazalp wrote:
    > hi guys,
    > this would be the most basic question ever...I am not a programmer but
    > I am trying to learn programming in python...I was reading John Zelle's
    > text book and instructed me to make .py file and save it on the desk
    > top...then it said close the python GUI and double click on the icon of
    > the I just made and that should run the program...well, the good news
    > is that it does but when I input a number for calculation and press the
    > enter key the program closes...Does any one know what the problem is?


    The DOS box closes as soon as the program terminates. To prevent that, add
    a call to raw_input() at the end of your script. Python will then prompt you
    for input, and therefore the window will stay open.

    Georg
    Georg Brandl, Apr 2, 2006
    #2
    1. Advertising

  3. aghazalp

    aghazalp Guest

    thanx george for the prompt answer... when you say add a call that
    means what exactly?...here is the program I was supposed to
    write...could you tell me what to add where in this program?

    def main():
    print "this program is crazy"
    x=input ('enter a number betwenen 0 and 1: ')
    for i range (10)
    x=3.9*x*(1-x)
    print x

    main()


    thanx again
    aghazalp, Apr 2, 2006
    #3
  4. aghazalp

    Georg Brandl Guest

    aghazalp wrote:
    > thanx george for the prompt answer... when you say add a call that
    > means what exactly?...here is the program I was supposed to
    > write...could you tell me what to add where in this program?
    >
    > def main():
    > print "this program is crazy"
    > x=input ('enter a number betwenen 0 and 1: ')
    > for i range (10)
    > x=3.9*x*(1-x)
    > print x
    >
    > main()


    At the very end of the program, that is here, after main(), just insert

    raw_input()

    Georg
    Georg Brandl, Apr 2, 2006
    #4
  5. aghazalp

    aghazalp Guest

    thanx ...it works great now...you re awesome...the only thing is that
    the program only executes once though...I guess I ll have to read up
    more anout it but for now that helped me a lot...I appreciated the help
    aghazalp, Apr 2, 2006
    #5
  6. aghazalp

    Larry Bates Guest

    aghazalp wrote:
    > thanx ...it works great now...you re awesome...the only thing is that
    > the program only executes once though...I guess I ll have to read up
    > more anout it but for now that helped me a lot...I appreciated the help
    >


    It only executes once because you only call it once.

    Your program:

    def main():
    print "this program is crazy"
    x=input ('enter a number betwenen 0 and 1: ')
    for i range (10)
    x=3.9*x*(1-x)
    print x

    main()

    Change to something like:

    def main():
    print "this program is crazy"
    while 1:
    x=input ('enter a number between 0 and 1 [-1 to exit]: ')
    if x == -1: break
    for i range (10)
    x=3.9*x*(1-x)
    print x

    main()


    -Larry Bates
    Larry Bates, Apr 2, 2006
    #6
  7. aghazalp

    aghazalp Guest

    WOWWWWWWWW Larry
    that was very very smart...it works perfectly =)
    aghazalp, Apr 2, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    454
    Raymond Hettinger
    Jul 27, 2003
  2. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,594
    Merrill & Michele
    Oct 19, 2004
  3. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    504
    Dave Thompson
    Feb 14, 2005
  4. mdh

    A very **very** basic question

    mdh, Sep 25, 2008, in forum: C Programming
    Replies:
    57
    Views:
    1,201
    August Karlstrom
    Sep 26, 2008
  5. Sunjay Varma
    Replies:
    4
    Views:
    333
    John Roth
    Mar 10, 2011
Loading...

Share This Page