Introduction to Python Programming

From Crowfly

Jump to: navigation, search

Contents

Log in

Log into a Unix computer. See your Systems Administrator for instructions. It might look like this:

  ssh [email protected]


First Program

The Hello World Program.

The Editor

Using an editor, like nano or another editor, create a new file called hello.py that contains the following:

print "Hello, World"

You can do that like this:

nano hello.py

This will open up the nano editor.

Then type: print "Hello, World." and [ENTER]

Then, as indicated at the bottom of the screen, type

 Control-X   to Exit Editor
 Y  - to say Yes to saving the file,
 [Enter] - to keep the same name of the file

Using Files

To see our new file type

ls hello.py

or using the -l for long format:

ls -l hello.py

To see all files, type

ls -l *

The * is a wildcard.

Using Directories

Make a special python subdirectory

mkdir python

Move your hello world program into the directory

mv hello.py python

Go into the new directory

cd python

See where you (print working directory)

pwd

See your files

ls -l

Runing Programs

python hello.py

Your program should display the words: "Hello, World."

Exercises

Do Assignment 4

See, also

Personal tools