2.0 Introduction To Python Programming Language: Page 1 of 4
2.0 Introduction To Python Programming Language: Page 1 of 4
Python is Interpreted: This means that it is processed at runtime by the interpreter and
you do not need to compile your program before executing it. This is similar to PERL
and PHP.
Python is Interactive: This means that you can actually sit at a Python prompt and
interact with the interpreter directly to write your programs.
Python is Object-Oriented: This means that Python supports Object-Oriented style or
technique of programming that encapsulates code within objects.
Python is Beginner's Language: Python is a great language for the beginner
programmers and supports the development of a wide range of applications from simple
text processing to WWW browsers to games.
Page 1 of 4
What sort of Language is Python?
The naïve view of computer languages is that they come as either compiled languages or
interpreted languages.
At the strictly compiled end languages like C, C++ or Fortran are "compiled"
(converted) into raw machine code for your computer. You point your CPU at that code and it
runs.
Slightly separate from the strictly compiled languages are languages like Java and C# (or
anything running in the .net framework). You do need to explicitly compile these programming
languages but they are compiled to machine code for a fake CPU which is then emulated on
whichever system you run on.
Then there is Python. Python does not have to be explicitly compiled but behind the scenes there
is a system that compiles Python into an intermediate code which is stashed away to make things
faster in future. But it does this without you having to do anything explicit yourself. So from the
point of view of how you use it you can treat it as a purely interpreted language like the shell or
Perl.
Page 2 of 4
Python first Command
After the typing the command above, press the return key.
This is our first Python “function”. A function takes some input, does something with it and
(optionally) returns a value. The nomenclature derives from the mathematics of functions, but we
don’t need to fixate on the mathematical underpinnings of computer science in this course.
Our function in this case is “print” and the command necessarily starts with the name of the
function. The inputs to the function are called its “arguments” and follow the function inside
round brackets (“parentheses”). In this case there is a single argument, the text to print.
Note that Python, as with many but not all programming languages, is “case sensitive”. The word
“print” is not the same as “Print” or “PRINT”.
Page 3 of 4
Use of quotes: “do-print-this”
If there are no quotes then Python will try to interpret the letters as something it should know
about. With the quotes Python simply interprets it as literal text.
For example, without quotes the string of characters p-r-i-n-t are a command; with quotes
they are the text to be printed. i.e, “print” and print
Python Scripts
Let’s create a test Python script - create a file called hello.py with the following contents.
#! python
A Python script can be executed at command line by invoking the interpreter on your
application.
Navigate to the directory where you have saved your python scripts, i.e, PythonScripts
Use the command: cd PythonScripts – then press enter key on the keyboard.
Page 4 of 4