Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 20 Online
OpenStudy (anonymous):

I just started the course. I'm a newcomer to programming and I was wondering if there was a 'run' button for python? or is it an exec function? if so how do you actually run your program after writing the code?

OpenStudy (anonymous):

Well, if you have python installed already, all you have to do is just...run it. Either run it right from your machine in command line, or if you have IDLE, run it in the interpreter. You can do that by pressing F5 while viewing any code file in IDLE.

OpenStudy (anonymous):

well python is an interpreter you can directly run the scripts from idle

OpenStudy (anonymous):

I'm on a mac actually, so do I just have to open it up through the Python launcher?

OpenStudy (anonymous):

I'm not on a mac myself so I don't know how it looks there, but wherever python is installed for you, just loke for IDLE. When you run that, that's the interpreter. To open a new window to edit code, just press ctrl+n.

OpenStudy (anonymous):

Alternatively you can run via terminal by typing python name.py where name is the name of the file and you have to be on the local of the file (use cd if that is the case). For a good text editor, I would suggest TextMate, Aquamacs or Vim. All three are good for Mac.

OpenStudy (anonymous):

I was confused about this at the beginning. There are several ways to get to Python and IDLE, and several ways to run and execute your code. You can do it through the graphic interface of your operating system or you can do it on a terminal/command prompt. You open IDLE which shows the prompts at the beginning of each line >> If you choose "new window"(or control n as others said) in IDLE, you will get a shell that does not have the prompts- I write all my code here. When you want the interpreter to run or test your code, press F5. (probably the same for a Mac but I'm not positive). You will be prompted to save the file (make sure to use .py) This will open up an IDLE window and display whatever you told it to (or will give you an error). Perfect way to test your syntax and output. When you are going back to open a saved python file, in a PC you right-click and get options to "Edit in IDLE" or to "Open". If you choose "Open", the program will execute in a command prompt/terminal. You probably access it by whatever the apple alternative is to right-clicking (single click on the icon?). One of the first programs I wrote was one suggested in the readings: the guessing game. You ask the user to guess what number you're thinking of. I had everyone in my family test that one out by executing it. It amused me and them for hours :D You can also access python through terminal like bmp said.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!