Professional Documents
Culture Documents
A BRIEF HISTORY
Python is a general-purpose programming language. That means you can use Python to write
code for any programming task. It is used in the Google search engine, in mission-critical
projects at NASA, and in transaction processing at the New York Stock Exchange.
Python is interpreted, which means that Python code is translated and executed by an
interpreter, one statement at a time.
NOTE:
The codes written in programming language (in this case, Python) are called source code
or source program. Because a computer cannot understand a source program. Therefore,
a source program or source code must be translated into machine code for execution. The
translation can be done using another programming tool called an Interpreter or a
Compiler.
▪ An Interpreter reads one statement from the source code, translates it to the
machine code, and then executes it right away.
▪ A Compiler translates the entire source code into a machine code file, and the
machine code file is then executed.
A function is a piece of prewritten code that performs operation. Python has numerous
built-in functions that perform various operations. Perhaps the most fundamental built-
in function is the print function, which displays output on the screen.
Here is an example of a statement that executes the print function:
print(‘Hello World’)
When programmers execute a function, they say that they are calling the function. An
argument is the data sent to the function when it is called. In the previous example, the
argument is ‘Hello World’. Notice that the quote marks are not displayed when the
statement executes. The quote marks simply specify the beginning and the end of the text
that you wish to display.
Program Output
print(‘Saint Catherine Academy’)
print(‘Happy Halloween!’) Saint Catherine Academy
Happy Halloween!
print(‘current year: 2022’)
current year: 2022
Programs almost work with data of some type. For example, the following three pieces
of data is used:
In Python you can enclose string literals in a set of single-quote marks (‘) or a set of double
quote marks (“).
Program Output
print(“Saint Catherine Academy”)
print(“Happy Halloween!”) Saint Catherine Academy
Happy Halloween!
print(“current year: 2022”) current year: 2022
Python also allows you to enclose string literals in triple quotes (either “”” or ‘’’). Triple
quotes can also be used to surround multiline strings, something for which single and
double quotes cannot be used. Here is an example:
NOTE:
Indentation matters in Python. Note that the statements are entered from the first column
in the new line. The Python interpreter will report an error if the program is typed as
follows:
print(“Welcome to Python”)
print(“Our class rock!”)
Don’t put any punctuation at the end of a statement outside the quote marks. The Python
interpreter will report errors for the following code:
print(“Welcome to Python”),
print(“Our class rock!”).
Python programs are case sensitive. It would be wrong for example, to replace print in
the program with Print.