You are on page 1of 3

INTRO TO PROGRAMMING USING PYTHON

A BRIEF HISTORY

Python was created by Guido van Rossum in the Netherlands in 1990


and was named after the popular British comedy troupe Monty
Python’s Flying Circus. Python has become a popular programming
language widely used in industry and academia due to its simple, concise, and intuitive
syntax and extensive library.

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.

Displaying OUTPUT with the print Function

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’)

Function Name Argument

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:

‘Saint Catherine Academy’


‘Happy Halloween!’
‘current year: 2022’

These pieces of data are sequences of characters. In programming terms, a sequence of


characters that is used as data is called a string. When a string appears in the actual code
of a program it is called a string literal. In Python code, string literals must be enclosed
in quote marks.

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:

print(‘’’One Program Output


Two
One
Three’’’) Two
Three

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.

You might also like