A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

I'm on Ubuntu 10.04, and I everytime I run my program, it appears for a split second, then disappears (Problem Set 0) is anyone willing to check my code? It follows: # Problem Set 0 # Name: Cody Dostal # Collaborators: None # Time: 0:02 #! /usr/bin/env python # print "What is your first name? " FirstName = raw_input() print "What is your last name? " LastName = raw_input() print "Hello, " + FirstName + " " + LastName -------------END---------- What is my Problem with it?

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    it runs fine in IDLE, just not when I save it as ps0.py

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I don't use Linux, but I can say that I always use IDLE for running and writing programs, never any sort of OS terminal. When I open a module (double clicking on one in the file management system of my mac or windows machines) it opens as a window in IDLE, and doesn't run until I specifically tell it to. From the line #! /usr/bin/env python and the "END" thing, it looks like you're using some flavor of terminal/command-line to run the code. There's probably a way to make that work, but if what you're looking for is just understanding Python, you won't miss anything by using IDLE.

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    that happens with me to, because it runs the code and after it is done it closes. To prevent this, type the following on the last line: raw_input("Press any key to exit")

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @somnamnic: The -----------END------------ was just so I could show that that was the end of my code :) But I am starting to learn more about IDLE and am falling in love with it! @not4sale93: I did that, but it still does it :( New code: # Assignment: Problem Set 0 # Name: Cody Dostal # Collaborators: None # Time: 0:05 # firstname = raw_input('What is your first name? ') lastname = raw_input('What is your last name? ') print 'Hello, ' + firstname + ' ' + lastname raw_input("Press any key to exit")

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I noticed that if I open terminal and type in: Python ps0.py it runs fine it's only when I double click it and say "Run in Terminal" :\

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    CodyWD, I think what you're running into is a normal behavior in Ubuntu. When you double-click to "Run in Terminal", the terminal window opens, runs the selected app, then closes. Nothing is telling the terminal window to stay open. You can "cheat" and add the following to the very end of your app (but don't brag about it to anyone :) ): raw_input("Press Enter to exit...") That line will keep the terminal window open long enough for you to see the output. But it's a kluge.

  7. Emil
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    CodyWD, a good alternative too see your code execution is to open a terminal and then execute the code. For example, press Ctrl+Alt+T to open a terminal, go to the folder where you have your .py file, and then execute like this : "python ps0.py". The terminal will remain open so you will see the results. Don't forget to enclose the Print arguments in ("brackets..") I hope this is useful...

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    @Radly: That doesn't seem to work at all :\ @Emil: Already done, but I think I'm going to start sticking to IDLE for line-by-line testing, and PyScripter+Windows 7 for full programs haha

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I use ubuntu also and I don't have a problem when I use raw_input() to make it block. If your code looks like: #!/usr/bin/python # whereis python to make sure it's that path firstname = raw_input('What is your first name? ') lastname = raw_input('What is your last name? ') print 'Hello, ' + firstname + ' ' + lastname raw_input("Press any key to exit") EOF Then you should have no problems

  10. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.