prev next 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Programs are just Scripts

A program is just a script that a computer reads as quickly as it can. If we put a lot of lines of code into a program, the computer will do them all, one after the other.

Try typing these extra lines into your TextEdit. Don't forget to save the file again.

#!/usr/bin/env python

print 'time to play hangman'
secret = 'crocodile'
for letter in secret:
  print '_',

Now run the program in Terminal.

You can use the up-arrow if you don't want to bother typing the name of your program again. After you have the name of your program, press return.


laptop:~ student$ Desktop/game.py
time to play hangman
_ _ _ _ _ _ _ _
laptop:~ student$  

See what happens? Everthing in your program ran very quickly.