Skip to content

Running Code

chuckablack edited this page Nov 17, 2020 · 1 revision

Overview

If you are "old school", i.e. you don't want to use an IDE, and prefer to just type your code into notepad or vi and then run it, and see what happens, you can feel free to do so. But if you want to join the 20th century (that's not a typo, David Bombal), then you'll be using an IDE of some type. Below I'll explain a few things about running your code from PyCharm's IDE.

Actually running the code

You have a few options for running your code in PyCharm:

  • Right-click your python filename in the project's explorer-style frame on the far left. If you do that, about half way down the pop-up menu, you'll see "run '. You'll see that green triangle 'play' associated with this item.
  • Right-click inside your python code, where you do your editing. You'll see a similar menu to the one above, and just click on the 'run' item.
  • Near the top-right, you'll see a box with a filename of the selected file you are editing. Assuming this is your python file, you can click the adjacent green 'play' button, next to it.

Checking the output

When you run your code, PyCharm will open an output window, usually at the bottom of PyCharm (you can move this, e.g. to the right, if you so choose). Here you will see various things:

  • The output from your code, assuming you have sprinkled 'print' statements in there liberally, as is a good idea at the beginning. This allows you to see the progress of your code.
  • Errors that Python may have encountered when running your code. Note that, assuming the error is of a certain severity, for runtime errors you will see the first error; if you fix that one, then run it again, you may encounter a subsequent error, further along.
Clone this wiki locally