Python by Swaroop C H - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

How It Works

Let us consider the first two lines of the program. These are called comments - anything to the right of the# symbol is a comment and is mainly useful as notes for the reader of the program.

Python does not use comments except for the special case of the first line here. It is called the shebang line - whenever the first two characters of the source file are#! followed by the location of a program, this tells your Linux/Unix system that this program should be run with this interpreter when you execute the program. This is explained in detail in the next section. Note that you can always run the program on any platform by specifying the interpreter directly on the command line such as the command python helloworld.py .

Important

Use comments sensibly in your program to explain some important details of your program this is useful for readers of your program so that they can easily understand what the program is doing. Remember, that person can be yourself after six months!

The comments are followed by a Python statement - this just prints the text'Hello World'. The print is actually an operator and'Hello World' is referred to as a string - don't worry, we will explore these terminologies in detail later.