need help with python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • adamurbas@hotmail.com

    #1

    need help with python

    ya so im pretty much a newb to this whole python thing... its pretty
    cool but i just started today and im already having trouble. i
    started to use a tutorial that i found somewhere and i followed the
    instructions and couldnt get the correct results. heres the code
    stuff...

    temperature=inp ut("what is the temperature of the spam?")
    if temperature>50:
    print "the salad is properly cooked."
    else:
    print "cook the salad some more."

    ya i was trying to do that but when i told it what the spams
    temperature was, it just turned off... well it wasnt working at all at
    first until i realized that i hadnt been following the instructions
    completely correctly and that i was supposed to type that code up in a
    notepad then save and open with python... so ya thats when it asked me
    what temperature the spam was and i typed a number then it just closed
    itself... im not really sure what went wrong... itd be real nice if
    someone would be like a mentor or something...

  • Ian Clark

    #2
    Re: need help with python

    On 11 May 2007 18:47:27 -0700, adamurbas@hotma il.com
    <adamurbas@hotm ail.comwrote:
    ya so im pretty much a newb to this whole python thing... its pretty
    cool but i just started today and im already having trouble. i
    started to use a tutorial that i found somewhere and i followed the
    instructions and couldnt get the correct results. heres the code
    stuff...
    >
    temperature=inp ut("what is the temperature of the spam?")
    if temperature>50:
    print "the salad is properly cooked."
    else:
    print "cook the salad some more."
    >
    ya i was trying to do that but when i told it what the spams
    temperature was, it just turned off... well it wasnt working at all at
    first until i realized that i hadnt been following the instructions
    completely correctly and that i was supposed to type that code up in a
    notepad then save and open with python... so ya thats when it asked me
    what temperature the spam was and i typed a number then it just closed
    itself... im not really sure what went wrong... itd be real nice if
    someone would be like a mentor or something...
    >
    I'm making a couple of assumptions here (correct me if I'm wrong):

    1. You're using windows
    2. You double clicked on the .py file

    What this does is open up a new terminal window and start execution of
    the program. The program will execute to completion and then the
    window will close automatically without waiting for you to tell it to
    (lovely isn't it?). To get around this you have a couple options:

    1. Run the script from the command line
    2. Put this at the end of the .py file: input('Press ENTER to continue')

    Ian

    Comment

    • adamurbas@hotmail.com

      #3
      Re: need help with python

      On May 11, 9:11 pm, "Ian Clark" <turb...@gmail. comwrote:
      On 11 May 2007 18:47:27 -0700, adamur...@hotma il.com
      >
      >
      >
      <adamur...@hotm ail.comwrote:
      ya so im pretty much a newb to this whole python thing... its pretty
      cool but i just started today and im already having trouble. i
      started to use a tutorial that i found somewhere and i followed the
      instructions and couldnt get the correct results. heres the code
      stuff...
      >
      temperature=inp ut("what is the temperature of the spam?")
      if temperature>50:
      print "the salad is properly cooked."
      else:
      print "cook the salad some more."
      >
      ya i was trying to do that but when i told it what the spams
      temperature was, it just turned off... well it wasnt working at all at
      first until i realized that i hadnt been following the instructions
      completely correctly and that i was supposed to type that code up in a
      notepad then save and open with python... so ya thats when it asked me
      what temperature the spam was and i typed a number then it just closed
      itself... im not really sure what went wrong... itd be real nice if
      someone would be like a mentor or something...
      >
      I'm making a couple of assumptions here (correct me if I'm wrong):
      >
      1. You're using windows
      2. You double clicked on the .py file
      >
      What this does is open up a new terminal window and start execution of
      the program. The program will execute to completion and then the
      window will close automatically without waiting for you to tell it to
      (lovely isn't it?). To get around this you have a couple options:
      >
      1. Run the script from the command line
      2. Put this at the end of the .py file: input('Press ENTER to continue')
      >
      Ian
      ok u used a bunch of fancy words in there... im not sure what a .py
      file is... i am using windows... i dont know what a terminal window is
      but im gonna asume that it is when you click the python thing... ya i
      kinda understand what ur sayin but the thing is i wanted it to give
      feedback to my question and why would it do that... hmmm very
      confusing... im not sure how to run the script from the command
      line... oh yeah the enter thing worked. thanks for that... oh the
      command line must be the lil black box... if i put it there then it
      will give me a bunch of syntax this and error that kinda stuff...
      thats why im putin it in the notepad and plus the tutorial said to...

      Comment

      • Paul McGuire

        #4
        Re: need help with python

        On May 11, 8:47 pm, adamur...@hotma il.com wrote:
        ya so im pretty much a newb to this whole python thing... its pretty
        cool but i just started today and im already having trouble. i
        started to use a tutorial that i found somewhere and i followed the
        instructions and couldnt get the correct results. heres the code
        stuff...
        >
        temperature=inp ut("what is the temperature of the spam?")
        if temperature>50:
        print "the salad is properly cooked."
        else:
        print "cook the salad some more."
        >
        ya i was trying to do that but when i told it what the spams
        temperature was, it just turned off... well it wasnt working at all at
        first until i realized that i hadnt been following the instructions
        completely correctly and that i was supposed to type that code up in a
        notepad then save and open with python... so ya thats when it asked me
        what temperature the spam was and i typed a number then it just closed
        itself... im not really sure what went wrong... itd be real nice if
        someone would be like a mentor or something...
        Well, this list has a varying level of mentoring and newbie-tolerance,
        with more latitude for people who have made some effort to start with
        before posting things like "here's my homework problem, please send me
        the working code so I can hand it in."

        I just ran your code interactively at the Python prompt, and it runs
        just fine. See?
        >>temperature=i nput("what is the temperature of the spam?")
        what is the temperature of the spam?55
        >>if temperature>50:
        .... print "the salad is properly cooked."
        .... else:
        .... print "the salad is properly cooked."
        ....
        the salad is properly cooked.

        I think the problem you are having is that, when you run your program
        by double-clicking on the xyz.py file in a file browser, the OS
        (Windows, I assume?) opens a separate console window, and runs the
        program, and then at the end of the program, CLOSES the window. I
        think your code is running just fine, I think your "the salad is
        whatever" messages get printed out, but afterward, your program ends,
        so the window closes before you can see how your salad turned out.

        A simple workaround you can do is to add to the end of your program
        this statement:

        input("<press return to end program>")

        This will cause the process to stop and wait for you to press the
        RETURN key, giving you time to stop and admire your salad results
        before closing the window.

        One final note: many people post in a "write like I talk" style. This
        is okay while telling your story ("well it wasn't working at all at
        first..."), and the ee cummings all-lower-case is passable, but please
        drop the "ya"s. They are a verbal tic that may be okay in person, but
        do not translate at all to written posts. At least you don't say
        "like" every other word, and I thank you for that! :)

        You can get a sense of other writing styles by reading through the
        comp.lang.pytho n archives. I would also recommend that you might find
        more folks in the "just getting started" phase posting to the python-
        tutor mailing list (go to http://mail.python.org/mailman/listinfo/tutor),
        and you can skim through posts there for many introductory topics.

        Good luck to you, and welcome to Python!

        -- Paul

        Comment

        • adamurbas@hotmail.com

          #5
          Re: need help with python

          On May 11, 9:34 pm, Paul McGuire <p...@austin.rr .comwrote:
          On May 11, 8:47 pm, adamur...@hotma il.com wrote:
          >
          >
          >
          ya so im pretty much a newb to this whole python thing... its pretty
          cool but i just started today and im already having trouble. i
          started to use a tutorial that i found somewhere and i followed the
          instructions and couldnt get the correct results. heres the code
          stuff...
          >
          temperature=inp ut("what is the temperature of the spam?")
          if temperature>50:
          print "the salad is properly cooked."
          else:
          print "cook the salad some more."
          >
          ya i was trying to do that but when i told it what the spams
          temperature was, it just turned off... well it wasnt working at all at
          first until i realized that i hadnt been following the instructions
          completely correctly and that i was supposed to type that code up in a
          notepad then save and open with python... so ya thats when it asked me
          what temperature the spam was and i typed a number then it just closed
          itself... im not really sure what went wrong... itd be real nice if
          someone would be like a mentor or something...
          >
          Well, this list has a varying level of mentoring and newbie-tolerance,
          with more latitude for people who have made some effort to start with
          before posting things like "here's my homework problem, please send me
          the working code so I can hand it in."
          >
          I just ran your code interactively at the Python prompt, and it runs
          just fine. See?
          >
          >temperature=in put("what is the temperature of the spam?")
          >
          what is the temperature of the spam?55>>if temperature>50:
          >
          ... print "the salad is properly cooked."
          ... else:
          ... print "the salad is properly cooked."
          ...
          the salad is properly cooked.
          >
          I think the problem you are having is that, when you run your program
          by double-clicking on the xyz.py file in a file browser, the OS
          (Windows, I assume?) opens a separate console window, and runs the
          program, and then at the end of the program, CLOSES the window. I
          think your code is running just fine, I think your "the salad is
          whatever" messages get printed out, but afterward, your program ends,
          so the window closes before you can see how your salad turned out.
          >
          A simple workaround you can do is to add to the end of your program
          this statement:
          >
          input("<press return to end program>")
          >
          This will cause the process to stop and wait for you to press the
          RETURN key, giving you time to stop and admire your salad results
          before closing the window.
          >
          One final note: many people post in a "write like I talk" style. This
          is okay while telling your story ("well it wasn't working at all at
          first..."), and the ee cummings all-lower-case is passable, but please
          drop the "ya"s. They are a verbal tic that may be okay in person, but
          do not translate at all to written posts. At least you don't say
          "like" every other word, and I thank you for that! :)
          >
          You can get a sense of other writing styles by reading through the
          comp.lang.pytho n archives. I would also recommend that you might find
          more folks in the "just getting started" phase posting to the python-
          tutor mailing list (go tohttp://mail.python.org/mailman/listinfo/tutor),
          and you can skim through posts there for many introductory topics.
          >
          Good luck to you, and welcome to Python!
          >
          -- Paul
          well... i just discovered another of my mistakes. i was writing it in
          notepad and not saving it as .py silly me... hoho ya that input thing
          to get it to make u press enter worked tho... but only with that
          one... ive got another one that i cant get to work even with the input
          message to press enter. Sorry about the bad grammar. I'm used to
          Myspace where no one gives a particular hoot about how you type. I
          hope this is better. I will follow that link though. Thanks for the
          help.

          Comment

          • Paul McGuire

            #6
            Re: need help with python

            On May 11, 9:41 pm, adamur...@hotma il.com wrote:
            On May 11, 9:34 pm, Paul McGuire <p...@austin.rr .comwrote:
            >
            >
            >
            >
            >
            On May 11, 8:47 pm, adamur...@hotma il.com wrote:
            >
            ya so im pretty much a newb to this whole python thing... its pretty
            cool but i just started today and im already having trouble. i
            started to use a tutorial that i found somewhere and i followed the
            instructions and couldnt get the correct results. heres the code
            stuff...
            >
            temperature=inp ut("what is the temperature of the spam?")
            if temperature>50:
            print "the salad is properly cooked."
            else:
            print "cook the salad some more."
            >
            ya i was trying to do that but when i told it what the spams
            temperature was, it just turned off... well it wasnt working at all at
            first until i realized that i hadnt been following the instructions
            completely correctly and that i was supposed to type that code up in a
            notepad then save and open with python... so ya thats when it asked me
            what temperature the spam was and i typed a number then it just closed
            itself... im not really sure what went wrong... itd be real nice if
            someone would be like a mentor or something...
            >
            Well, this list has a varying level of mentoring and newbie-tolerance,
            with more latitude for people who have made some effort to start with
            before posting things like "here's my homework problem, please send me
            the working code so I can hand it in."
            >
            I just ran your code interactively at the Python prompt, and it runs
            just fine. See?
            >
            >>temperature=i nput("what is the temperature of the spam?")
            >
            what is the temperature of the spam?55>>if temperature>50:
            >
            ... print "the salad is properly cooked."
            ... else:
            ... print "the salad is properly cooked."
            ...
            the salad is properly cooked.
            >
            I think the problem you are having is that, when you run your program
            by double-clicking on the xyz.py file in a file browser, the OS
            (Windows, I assume?) opens a separate console window, and runs the
            program, and then at the end of the program, CLOSES the window. I
            think your code is running just fine, I think your "the salad is
            whatever" messages get printed out, but afterward, your program ends,
            so the window closes before you can see how your salad turned out.
            >
            A simple workaround you can do is to add to the end of your program
            this statement:
            >
            input("<press return to end program>")
            >
            This will cause the process to stop and wait for you to press the
            RETURN key, giving you time to stop and admire your salad results
            before closing the window.
            >
            One final note: many people post in a "write like I talk" style. This
            is okay while telling your story ("well it wasn't working at all at
            first..."), and the ee cummings all-lower-case is passable, but please
            drop the "ya"s. They are a verbal tic that may be okay in person, but
            do not translate at all to written posts. At least you don't say
            "like" every other word, and I thank you for that! :)
            >
            You can get a sense of other writing styles by reading through the
            comp.lang.pytho n archives. I would also recommend that you might find
            more folks in the "just getting started" phase posting to the python-
            tutor mailing list (go tohttp://mail.python.org/mailman/listinfo/tutor),
            and you can skim through posts there for many introductory topics.
            >
            Good luck to you, and welcome to Python!
            >
            -- Paul
            >
            well... i just discovered another of my mistakes. i was writing it in
            notepad and not saving it as .py silly me... hoho ya that input thing
            to get it to make u press enter worked tho... but only with that
            one... ive got another one that i cant get to work even with the input
            message to press enter. Sorry about the bad grammar. I'm used to
            Myspace where no one gives a particular hoot about how you type. I
            hope this is better. I will follow that link though. Thanks for the
            help.- Hide quoted text -
            >
            - Show quoted text -
            It's possible that your next program has a runtime error, which will
            raise an exception that, if not handled using try-except, will cause
            the program to exit with a message (a message that will flash by and
            then disappear, as the window closes immediately).

            One thing you should try is to run your python programs using a
            terminal window (sometimes called a "console window", or "the command
            line"). There are several ways to open one of these, the simplest on
            Windows is to click the "Start" button in the lower left corner,
            select "Run...", and enter the command "cmd". This will open up one
            of these white-letters-on-black-background windows for typing system
            commands. From this command line, you can run your Python programs by
            typing "python blah.py" where blah.py is the name of your Python
            script (which you created in Notepad and saved as blah.py. By running
            scripts this way, you will get to see *all* of your program output,
            without having the window close on you. (and please don't name all
            your scripts "blah.py", you should pick different names...)

            Another thing you might try is downloading and installing SciTE for
            Windows - a free super-Notepad, with built-in support for editing *and
            running* Python scripts. Enter your Python code, save it as
            "whatever.p y", then press F5 - the editor will split down the middle,
            keeping your program in the left half, and show the output messages
            and exceptions on the right. I find this much easier than going back
            and forth between Notepad and a terminal window. Other developer
            editors (often called "IDE"s for Interactive Development Environment)
            work similarly, such as pythonwin or IDLE - there are many others to
            choose from, but coming from Notepad, SciTE will not be a big step,
            but will move you forward.

            -- Paul

            Comment

            • adamurbas@hotmail.com

              #7
              Re: need help with python

              On May 11, 10:16 pm, Paul McGuire <p...@austin.rr .comwrote:
              On May 11, 9:41 pm, adamur...@hotma il.com wrote:
              >
              >
              >
              On May 11, 9:34 pm, Paul McGuire <p...@austin.rr .comwrote:
              >
              On May 11, 8:47 pm, adamur...@hotma il.com wrote:
              >
              ya so im pretty much a newb to this whole python thing... its pretty
              cool but i just started today and im already having trouble. i
              started to use a tutorial that i found somewhere and i followed the
              instructions and couldnt get the correct results. heres the code
              stuff...
              >
              temperature=inp ut("what is the temperature of the spam?")
              if temperature>50:
              print "the salad is properly cooked."
              else:
              print "cook the salad some more."
              >
              ya i was trying to do that but when i told it what the spams
              temperature was, it just turned off... well it wasnt working at all at
              first until i realized that i hadnt been following the instructions
              completely correctly and that i was supposed to type that code up in a
              notepad then save and open with python... so ya thats when it asked me
              what temperature the spam was and i typed a number then it just closed
              itself... im not really sure what went wrong... itd be real nice if
              someone would be like a mentor or something...
              >
              Well, this list has a varying level of mentoring and newbie-tolerance,
              with more latitude for people who have made some effort to start with
              before posting things like "here's my homework problem, please send me
              the working code so I can hand it in."
              >
              I just ran your code interactively at the Python prompt, and it runs
              just fine. See?
              >
              >temperature=in put("what is the temperature of the spam?")
              >
              what is the temperature of the spam?55>>if temperature>50:
              >
              ... print "the salad is properly cooked."
              ... else:
              ... print "the salad is properly cooked."
              ...
              the salad is properly cooked.
              >
              I think the problem you are having is that, when you run your program
              by double-clicking on the xyz.py file in a file browser, the OS
              (Windows, I assume?) opens a separate console window, and runs the
              program, and then at the end of the program, CLOSES the window. I
              think your code is running just fine, I think your "the salad is
              whatever" messages get printed out, but afterward, your program ends,
              so the window closes before you can see how your salad turned out.
              >
              A simple workaround you can do is to add to the end of your program
              this statement:
              >
              input("<press return to end program>")
              >
              This will cause the process to stop and wait for you to press the
              RETURN key, giving you time to stop and admire your salad results
              before closing the window.
              >
              One final note: many people post in a "write like I talk" style. This
              is okay while telling your story ("well it wasn't working at all at
              first..."), and the ee cummings all-lower-case is passable, but please
              drop the "ya"s. They are a verbal tic that may be okay in person, but
              do not translate at all to written posts. At least you don't say
              "like" every other word, and I thank you for that! :)
              >
              You can get a sense of other writing styles by reading through the
              comp.lang.pytho n archives. I would also recommend that you might find
              more folks in the "just getting started" phase posting to the python-
              tutor mailing list (go tohttp://mail.python.org/mailman/listinfo/tutor),
              and you can skim through posts there for many introductory topics.
              >
              Good luck to you, and welcome to Python!
              >
              -- Paul
              >
              well... i just discovered another of my mistakes. i was writing it in
              notepad and not saving it as .py silly me... hoho ya that input thing
              to get it to make u press enter worked tho... but only with that
              one... ive got another one that i cant get to work even with the input
              message to press enter. Sorry about the bad grammar. I'm used to
              Myspace where no one gives a particular hoot about how you type. I
              hope this is better. I will follow that link though. Thanks for the
              help.- Hide quoted text -
              >
              - Show quoted text -
              >
              It's possible that your next program has a runtime error, which will
              raise an exception that, if not handled using try-except, will cause
              the program to exit with a message (a message that will flash by and
              then disappear, as the window closes immediately).
              >
              One thing you should try is to run your python programs using a
              terminal window (sometimes called a "console window", or "the command
              line"). There are several ways to open one of these, the simplest on
              Windows is to click the "Start" button in the lower left corner,
              select "Run...", and enter the command "cmd". This will open up one
              of these white-letters-on-black-background windows for typing system
              commands. From this command line, you can run your Python programs by
              typing "python blah.py" where blah.py is the name of your Python
              script (which you created in Notepad and saved as blah.py. By running
              scripts this way, you will get to see *all* of your program output,
              without having the window close on you. (and please don't name all
              your scripts "blah.py", you should pick different names...)
              >
              Another thing you might try is downloading and installing SciTE for
              Windows - a free super-Notepad, with built-in support for editing *and
              running* Python scripts. Enter your Python code, save it as
              "whatever.p y", then press F5 - the editor will split down the middle,
              keeping your program in the left half, and show the output messages
              and exceptions on the right. I find this much easier than going back
              and forth between Notepad and a terminal window. Other developer
              editors (often called "IDE"s for Interactive Development Environment)
              work similarly, such as pythonwin or IDLE - there are many others to
              choose from, but coming from Notepad, SciTE will not be a big step,
              but will move you forward.
              >
              -- Paul
              I was looking around in my Python folder and saw something to do with
              that IDLE thing you were talking about. When I right clicked on a .py
              file, it said edit with IDLE. I opened it and it was my code but each
              line was a different color. It looked confusing so I decide to save
              it for later. I knew that I could get the run thing to do the command
              thing, but I had forgotten how to get the black window to come up.

              Ok. Well, I tried to us the cmd window. It says python: can't open
              file 'area.py' I'm guessing that's not good. It won't open any of
              my .py files. It's because of where I saved them. I can see how this
              i going to work now. Ok so I'll just move them to the place that the
              command line says. Now it still won't run my other program:

              # Area calculation program

              print "Welcome to the Area calculation program"
              print "-------------"
              print

              # Print out the menu:
              print "Please select a shape:"
              print "1 Rectangle"
              print "2 Circle"

              # Get the user's choice:
              shape = input("")

              # Calculate the area:
              if shape == 1:
              height = input("Please enter the height: ")
              width = input("Please enter the width: ")
              area = height*width
              print "The area is", area
              else:
              radius = input("Please enter the radius: ")
              area = 3.14*(radius**2 )
              print "The area is", area

              Perhaps it isn't written correctly. I don't think it likes the pound
              signs. I'm not sure. But, I did go to that mailing list you
              recommended. Thanks for that.

              Comment

              • Paul McGuire

                #8
                Re: need help with python

                On May 11, 10:37 pm, adamur...@hotma il.com wrote:
                On May 11, 10:16 pm, Paul McGuire <p...@austin.rr .comwrote:
                >
                >
                >
                >
                >
                On May 11, 9:41 pm, adamur...@hotma il.com wrote:
                >
                On May 11, 9:34 pm, Paul McGuire <p...@austin.rr .comwrote:
                >
                On May 11, 8:47 pm, adamur...@hotma il.com wrote:
                >
                ya so im pretty much a newb to this whole python thing... its pretty
                cool but i just started today and im already having trouble. i
                started to use a tutorial that i found somewhere and i followed the
                instructions and couldnt get the correct results. heres the code
                stuff...
                >
                temperature=inp ut("what is the temperature of the spam?")
                if temperature>50:
                print "the salad is properly cooked."
                else:
                print "cook the salad some more."
                >
                ya i was trying to do that but when i told it what the spams
                temperature was, it just turned off... well it wasnt working at all at
                first until i realized that i hadnt been following the instructions
                completely correctly and that i was supposed to type that code up in a
                notepad then save and open with python... so ya thats when it asked me
                what temperature the spam was and i typed a number then it just closed
                itself... im not really sure what went wrong... itd be real nice if
                someone would be like a mentor or something...
                >
                Well, this list has a varying level of mentoring and newbie-tolerance,
                with more latitude for people who have made some effort to start with
                before posting things like "here's my homework problem, please send me
                the working code so I can hand it in."
                >
                I just ran your code interactively at the Python prompt, and it runs
                just fine. See?
                >
                >>temperature=i nput("what is the temperature of the spam?")
                >
                what is the temperature of the spam?55>>if temperature>50:
                >
                ... print "the salad is properly cooked."
                ... else:
                ... print "the salad is properly cooked."
                ...
                the salad is properly cooked.
                >
                I think the problem you are having is that, when you run your program
                by double-clicking on the xyz.py file in a file browser, the OS
                (Windows, I assume?) opens a separate console window, and runs the
                program, and then at the end of the program, CLOSES the window. I
                think your code is running just fine, I think your "the salad is
                whatever" messages get printed out, but afterward, your program ends,
                so the window closes before you can see how your salad turned out.
                >
                A simple workaround you can do is to add to the end of your program
                this statement:
                >
                input("<press return to end program>")
                >
                This will cause the process to stop and wait for you to press the
                RETURN key, giving you time to stop and admire your salad results
                before closing the window.
                >
                One final note: many people post in a "write like I talk" style. This
                is okay while telling your story ("well it wasn't working at all at
                first..."), and the ee cummings all-lower-case is passable, but please
                drop the "ya"s. They are a verbal tic that may be okay in person, but
                do not translate at all to written posts. At least you don't say
                "like" every other word, and I thank you for that! :)
                >
                You can get a sense of other writing styles by reading through the
                comp.lang.pytho n archives. I would also recommend that you might find
                more folks in the "just getting started" phase posting to the python-
                tutor mailing list (go tohttp://mail.python.org/mailman/listinfo/tutor),
                and you can skim through posts there for many introductory topics.
                >
                Good luck to you, and welcome to Python!
                >
                -- Paul
                >
                well... i just discovered another of my mistakes. i was writing it in
                notepad and not saving it as .py silly me... hoho ya that input thing
                to get it to make u press enter worked tho... but only with that
                one... ive got another one that i cant get to work even with the input
                message to press enter. Sorry about the bad grammar. I'm used to
                Myspace where no one gives a particular hoot about how you type. I
                hope this is better. I will follow that link though. Thanks for the
                help.- Hide quoted text -
                >
                - Show quoted text -
                >
                It's possible that your next program has a runtime error, which will
                raise an exception that, if not handled using try-except, will cause
                the program to exit with a message (a message that will flash by and
                then disappear, as the window closes immediately).
                >
                One thing you should try is to run your python programs using a
                terminal window (sometimes called a "console window", or "the command
                line"). There are several ways to open one of these, the simplest on
                Windows is to click the "Start" button in the lower left corner,
                select "Run...", and enter the command "cmd". This will open up one
                of these white-letters-on-black-background windows for typing system
                commands. From this command line, you can run your Python programs by
                typing "python blah.py" where blah.py is the name of your Python
                script (which you created in Notepad and saved as blah.py. By running
                scripts this way, you will get to see *all* of your program output,
                without having the window close on you. (and please don't name all
                your scripts "blah.py", you should pick different names...)
                >
                Another thing you might try is downloading and installing SciTE for
                Windows - a free super-Notepad, with built-in support for editing *and
                running* Python scripts. Enter your Python code, save it as
                "whatever.p y", then press F5 - the editor will split down the middle,
                keeping your program in the left half, and show the output messages
                and exceptions on the right. I find this much easier than going back
                and forth between Notepad and a terminal window. Other developer
                editors (often called "IDE"s for Interactive Development Environment)
                work similarly, such as pythonwin or IDLE - there are many others to
                choose from, but coming from Notepad, SciTE will not be a big step,
                but will move you forward.
                >
                -- Paul
                >
                I was looking around in my Python folder and saw something to do with
                that IDLE thing you were talking about. When I right clicked on a .py
                file, it said edit with IDLE. I opened it and it was my code but each
                line was a different color. It looked confusing so I decide to save
                it for later. I knew that I could get the run thing to do the command
                thing, but I had forgotten how to get the black window to come up.
                >
                Ok. Well, I tried to us the cmd window. It says python: can't open
                file 'area.py' I'm guessing that's not good. It won't open any of
                my .py files. It's because of where I saved them. I can see how this
                i going to work now. Ok so I'll just move them to the place that the
                command line says. Now it still won't run my other program:
                >
                # Area calculation program
                >
                print "Welcome to the Area calculation program"
                print "-------------"
                print
                >
                # Print out the menu:
                print "Please select a shape:"
                print "1 Rectangle"
                print "2 Circle"
                >
                # Get the user's choice:
                shape = input("")
                >
                # Calculate the area:
                if shape == 1:
                height = input("Please enter the height: ")
                width = input("Please enter the width: ")
                area = height*width
                print "The area is", area
                else:
                radius = input("Please enter the radius: ")
                area = 3.14*(radius**2 )
                print "The area is", area
                >
                Perhaps it isn't written correctly. I don't think it likes the pound
                signs. I'm not sure. But, I did go to that mailing list you
                recommended. Thanks for that.- Hide quoted text -
                >
                - Show quoted text -
                Again, this runs just fine for me. Here is the output when run within
                SciTE:


                Welcome to the Area calculation program
                -------------

                Please select a shape:
                1 Rectangle
                2 Circle
                1
                Please enter the height: 10
                Please enter the width: 20
                The area is 200


                Welcome to the Area calculation program
                -------------

                Please select a shape:
                1 Rectangle
                2 Circle
                2
                Please enter the radius: 10
                The area is 314.0


                It seems like you are still struggling with mechanics of files,
                directories, etc., although your last post indicates you're making
                some progress there.

                Now for a better posting hint. When you tell us "Now it still won't
                run my other program", this isn't really enough to go on. What
                happens when you type in "python area.py" (assuming that you have used
                the 'cd' command to change your directory to the one containing
                area.py)? When you post that something doesn't work, copy/paste the
                error messages themselves into the post, and the actual Python code
                that you ran.

                But your problems do not seem to be Python problems at all, just OS
                and script execution mechanics.

                -- Paul

                Comment

                • BartlebyScrivener

                  #9
                  Re: need help with python

                  I'm not sure how you installed Python, or how you are using it, but I
                  made something last year to help Windows XP users who are brand new to
                  Python and can't get things to run, etc.

                  You might try either jumping into somewhere midway, or if you keep
                  having trouble, uninstall whatever you installed and start over using
                  this:

                  Critically-acclaimed novelist Richard Dooling is the author of five novels, along with two nonfiction works.


                  If that link breaks, use this:

                  http://tinyurl.com/w7wgp

                  Good luck.

                  rd


                  Comment

                  • adamurbas@hotmail.com

                    #10
                    Re: need help with python

                    On May 12, 11:55 am, BartlebyScriven er <bscrivene...@g mail.comwrote:
                    I'm not sure how you installed Python, or how you are using it, but I
                    made something last year to help Windows XP users who are brand new to
                    Python and can't get things to run, etc.
                    >
                    You might try either jumping into somewhere midway, or if you keep
                    having trouble, uninstall whatever you installed and start over using
                    this:
                    >
                    http://www.richarddooling.com/index....on-on-xp-7-min...
                    >
                    If that link breaks, use this:
                    >
                    http://tinyurl.com/w7wgp
                    >
                    Good luck.
                    >
                    rd
                    That is one of my problems, I don't know exactly how the whole command
                    line thing works. The other day, I got it to open python by itself,
                    but I accidentally closed the window and couldn't get it to work
                    again. I know how to do file paths and stuff but I'm not sure what to
                    put directly after it says C:\Documents and Settings\HP_Own er>. Do I
                    leave it like that and then put the next location in the line? Like
                    this:
                    C:\Documents and Settings\HP_Own erPython 2.5.1\Python area.py
                    Or is that wrong. I've already uninstalled and reinstalled because I
                    couldn't copy and paste it to another location, so I just reinstalled
                    it to HP_Owner. I'll try that link.
                    Thanks.

                    Comment

                    • Paul McGuire

                      #11
                      Re: need help with python

                      On May 13, 10:10 am, adamur...@hotma il.com wrote:
                      On May 12, 11:55 am, BartlebyScriven er <bscrivene...@g mail.comwrote:
                      >
                      >
                      >
                      >
                      >
                      I'm not sure how you installed Python, or how you are using it, but I
                      made something last year to help Windows XP users who are brand new to
                      Python and can't get things to run, etc.
                      >
                      You might try either jumping into somewhere midway, or if you keep
                      having trouble, uninstall whatever you installed and start over using
                      this:
                      >>
                      If that link breaks, use this:
                      >>
                      Good luck.
                      >
                      rd
                      >
                      That is one of my problems, I don't know exactly how the whole command
                      line thing works. The other day, I got it to open python by itself,
                      but I accidentally closed the window and couldn't get it to work
                      again. I know how to do file paths and stuff but I'm not sure what to
                      put directly after it says C:\Documents and Settings\HP_Own er>. Do I
                      leave it like that and then put the next location in the line? Like
                      this:
                      C:\Documents and Settings\HP_Own erPython 2.5.1\Python area.py
                      Or is that wrong. I've already uninstalled and reinstalled because I
                      couldn't copy and paste it to another location, so I just reinstalled
                      it to HP_Owner. I'll try that link.
                      Thanks.- Hide quoted text -
                      >
                      - Show quoted text -
                      cd <new directory>

                      will change your current directory to <new directory>. Type "help"
                      after the "C:\Documen ts and Settings\HP_Own er>" (which is called the
                      'prompt') to get a summarized list of commands, or "help <command>" to
                      get help on that particular command. For instance try typing this at
                      the command line prompt:

                      help cd

                      and you'll get a lot more info on the cd command.

                      It sounds like a Windows tutorial would not be wasted time for you,
                      especially one that helps with the whole command line thing. You'll
                      learn about files, directories, deleting, renaming, and so on.

                      -- Paul

                      Comment

                      • BartlebyScrivener

                        #12
                        Re: need help with python

                        On May 13, 10:10 am, adamur...@hotma il.com wrote:
                        >
                        That is one of my problems, I don't know exactly how the whole command
                        line thing works.
                        That's why I pointed you to the link. The ActiveState distribution
                        will automatically add the correct paths to your environment and tell
                        Windows that .py files are executable Python files and so on.

                        Get ActiveState installed. Get comfortable with the Python IDE.

                        Then follow the instructions in Alan Gauld's tutorial.



                        Especially, in your case, the GETTING STARTED section, which includes
                        a subsection called "The Windows Command Prompt"

                        rd

                        Comment

                        • James T. Dennis

                          #13
                          Re: need help with python

                          adamurbas@hotma il.com wrote:
                          On May 11, 10:16 pm, Paul McGuire <p...@austin.rr .comwrote:
                          >On May 11, 9:41 pm, adamur...@hotma il.com wrote:
                          [... much ellided ...]

                          ["ellided" is a fancy word for "left out" or "replaced
                          with ellipses."]
                          I was looking around in my Python folder and saw something to do with
                          that IDLE thing you were talking about. When I right clicked on a .py
                          file, it said edit with IDLE. I opened it and it was my code but each
                          line was a different color. It looked confusing so I decide to save
                          it for later. I knew that I could get the run thing to do the command
                          thing, but I had forgotten how to get the black window to come up.
                          Idle is an "IDE" (integrated development environment). It's sort
                          of like an editor and a "terminal window" ("command shell") combined.
                          The different colors are the result of a feature called "syntax
                          highlighting" which is available in most of the modern IDEs and better
                          text editors.

                          To "get the black window to come up" use the [Start] menu, choose
                          the "Run" option and type in the name of the program: "cmd" (then
                          hit [Enter]).

                          You can can also find it if you chase far enough down the various
                          sub-menus off the [Start] menu.

                          Ok. Well, I tried to us the cmd window. It says python: can't open
                          file 'area.py' I'm guessing that's not good. It won't open any of
                          my .py files. It's because of where I saved them. I can see how this
                          i going to work now. Ok so I'll just move them to the place that the
                          command line says. Now it still won't run my other program:
                          Yes it's because of where you saved them and because of where the
                          command prompt (The C:\thing that you see inside the "terminal window").

                          Rather than moving your .py files to wherever your prompt is pointing,
                          it's generally better to change your prompt to point to the right place.

                          For example if you've been saving you .py files to "C:\My Documents" then
                          type:

                          cd "\My Documents"

                          ... (with the quotes around it).

                          Then try to run your files from there.
                          # Area calculation program
                          print "Welcome to the Area calculation program"
                          print "-------------"
                          print
                          # Print out the menu:
                          print "Please select a shape:"
                          print "1 Rectangle"
                          print "2 Circle"
                          # Get the user's choice:
                          shape = input("")
                          # Calculate the area:
                          if shape == 1:
                          height = input("Please enter the height: ")
                          width = input("Please enter the width: ")
                          area = height*width
                          print "The area is", area
                          else:
                          radius = input("Please enter the radius: ")
                          area = 3.14*(radius**2 )
                          print "The area is", area
                          Perhaps it isn't written correctly. I don't think it likes the pound
                          signs. I'm not sure. But, I did go to that mailing list you
                          recommended. Thanks for that.
                          The pound signs are used by Python to mark "comments" (stuff the
                          Python interpreter ignores; that's there just as hints and reminders
                          to humans who are reading the source code).

                          So, from the first # sign on a line until the end of the line Python
                          is ignoring everything.

                          The only exceptions to this rule are when the # is inside quotes:

                          print "This is technically called an octothorpe: #. See?"

                          ... in that line the octothorpe (#) is part of a quoted string
                          so it and the text following it are NOT ignored.

                          Incidentally, I would use the raw_input() function in place of
                          the input() function that these examples have been using.

                          The problem with the Python input() function is that it parses
                          the input as if it were Python code. So it will raise an
                          exception for any input you enter which is NOT valid, legal
                          Python code. (So far you've been lucky in that you've only been
                          using it to enter simple numbers, which are, of course, valid
                          Python expressions.

                          You can actually get away with inserting one line:

                          input = raw_input

                          ... near the beginning of any of your code examples to alleviate
                          this issue. The raw_input() function will accept any string you can
                          enter up to the first [Enter] key. (Actually on my platform, Linux,
                          it's possible to embed newline and/or carriage return characters
                          --- the ASCII characters which are normally generated by the [Enter]
                          key on various computing platforms --- into a raw_input() value by
                          preceding each of them with a Ctrl-V key. Just off hand I don't
                          know if that works under Windows using a command prompt window.
                          Just pointing that out for other readers to make the observation that
                          Python's raw_input() might not be as "raw" as you might expect).


                          --
                          Jim Dennis,
                          Starshine: Signed, Sealed, Delivered

                          Comment

                          Working...