Open a command window

o If you're using Mac OS X, open the Terminal application and select File 1 \ New Shell.

o If you're using Windows, open the Command Prompt window. o If you're using UNIX, either open a new shell window or just type in your existing shell window.

2. Type python.

When Python opens, you see the text shown in Figure 2-1.

When Python's interactive mode starts up, it tells you what version is running, the date the version was released, and a few hints about what to do next. Then it displays the Python prompt: >>>

^ -ivfii!

BaraifLl tpFtboa

¡V.ran 2. Sfck « rtSbL r47DJ8k, ?vn ¡ 0 24K# 16 i L7 nSS-1 1 CET 4.Û.Ï fAjipla CxtjîiiIj Hxta. fc-uilel ! JHiI | ' or. d«rwL-

*M|kP " ifht" . "ajt^JIti!F ■>! "Hovm*' toe. k>c« infviut Ion r

»>

Figure 2-1: Python's interactive mode in a Terminal window.

Why computers are always saying "Hello, World!"

Why computers are always saying "Hello, World!"

"Hello, World" programs are a computer programming tradition. According to the free Internet encyclopedia Wikipedia (http://www.wikipedia.org), the first instance of a computer program that printed "Hello, World" occurred in 1973, in a book called A Tutorial Introduction to the Language B, by Brian Kernighan. Since then, a "Hello, World!" program has been written for almost every computer language. Wikipedia lists more than 170 "Hello, World!" programs written in languages from 4GL and ActionScript to UNIX shell and XUL.

One reason that "Hello, World" programs are popular is that a program that prints a single statement is usually the shortest working program in a language.

• In Python, the shortest working program is one line long.

• In Java, the program is five lines long.

Aren't you glad you're using Python?

Was this article helpful?

0 0

Post a comment