batch mode

(“Batch” means “non-interactive.”)

In this section, you will write your Python commands in a text file instead of typing them into the Python shell. You’ll need a good text editor for that. If you’re on Windows, the default text editor is Notepad, a terrible editor. Instead, I recommend Notepad++. If you’re on Linux or OS X, whatever the default is will probably be fine.

Open your text editor and type the line print("hello world"), like so:

hello world

Then save the file as On Windows, I recommend that you save the file in “Computer” → “Local Disk (C:)” → “Users” → [your user name] → create a new folder called “programs”. So the location of the file will be C:\Users\YourUsername\programs\

Now open the command line and use cd to navigate to the directory where you saved your program. If you’re on Windows and you followed my advice above, you can open a new command prompt and type cd programs.

Once you’re there, you can run your program with python

$ python
hello world

You did it! Try making changes to the text file and re-running the program (don’t forget to save the text file each time).

The next page contains your first programming challenge.

previous: input next: basic io