The installation actually installs not only Python, but an editor program called "IDLE". You should be able to find IDLE under your applications menu.
When you execute it, you should see a window like this:
The IDLE shell
This window is called a "shell". It is waiting for you to enter commands to be executed. When you enter commands, it runs them right away and then waits for you to enter another command.
We can type our print command in here, to ask the shell to print something to the screen for us. We can also use it as a sort of calculator:
Entering commands into IDLE
This is one way to run Python code: interactively in the shell.
Using the shell is great for a powerful calculator, or for trying things out, but we don't normally write whole programs in it for a few reasons:
For those reasons, we normally write programs in a file, and run the whole thing at once. To do this, click "File->New File" on the menu bar. This will open a second window:
The shell is on the left, our new file on the right
This window does not have the shell prompt (>>>). If we type a print message into it, it won't execute right away like it does in the shell.
Instead we have to run the whole file. To do this, click "Run->Run Module", or hit the F5 key. If the program has not been saved yet, it will ask you to save it. Make sure to save it some place you will be able to find it later!. After it's saved, the program will run in the shell window:
Successfully running a Python program
For this lab you should create a Python program which prints your name to the screen. You can also add another print message, if you want to.
Be sure to write your program into a file and not the shell! You should save the file as something ending in .py, and run it using "Run->Run Module" to be sure that it works.
Copyright © 2018 Ian Finlayson | Licensed under a Creative Commons Attribution 4.0 International License.