COMP1021
Introduction to Computer Science
Getting Started with Python
David Rossiter and Gibson Lam
Outcomes
• After completing this presentation, you are
expected to be able to:
1. Understand the history and some background
information of the Python programming
language
2. Briefly explain the difference between a
compiled and an interpreted program
3. Install Python and start using Python through
the command line tool and IDLE
COMP1021 Getting Started with Python Page 2
Computer Programming Languages
• Computer programming languages have been
developed over the last 50 years
• There are hundreds of them
• For this course we will use a language called
Python
COMP1021 Getting Started with Python Page 3
1950s
Evolution of
1960s
Programming
Languages
1970s
• Only the main
programming 1980s
languages are
shown here
1990s
• We can ignore
all of them
except Python 2000s
From [Link]
language-study/[Link]
2010s
Guido Van
Python Rossum
• Started by a guy who was bored during Christmas 1989
• He made a computer language with these qualities:
– a language just as powerful as other languages
– code that is almost as understandable as simple English
– suitable for everyday tasks, so you can quickly make a
useful program
– open source, so anyone can contribute to its development
COMP1021 Getting Started with Python Page 5
Running a
Program
• Most of the programs on
your computer are .exe files
• For example, if you run
Microsoft Word, it means
the file [Link] is
being executed
• Microsoft Word is a program that has been compiled
into [Link], so it can be directly run by a
computer
COMP1021 Getting Started with Python Page 6
Running a Compiled Program
User
Program
• A computer can understand and directly run an exe file
COMP1021 Getting Started with Python Page 7
Executing a Python Program
• Python programs are a bit different, they have to
be ‘given’ to a Python interpreter for execution
Python User
source
code
Python
interpreter
[Link] [Link]
• We say that Python code is interpreted
• This is the most common way that Python is used
Python is Interpreted
• Interpreted means that each line of code is given
to the interpreter and executed, one by one
User
Python
source code
Python
interpreter
[Link] [Link]
• In this course we won’t look at the difference
between interpreting and compiling any further
Different Versions of Python
• Python version 1 – this version disappeared a long time ago
• Python version 2 – this version officially died early 2020
• Python version 3 – this version is what we use
• Python 3.8 is the version we use this semester
• You can install it in your own computer, see next slide
• You can also run it virtually – details a few slides later
• (It has also been installed in all the ITSC computer barns
and the CS department labs)
COMP1021 Getting Started with Python Page 10
How to Install Python 3.8?
• To install Python on your own PC/Mac system, you can
get the installation files from the COMP1021 web site:
PC users
Mac users
The ITSC Virtual Barn
• The ITSC virtual barn lets you access
Python (and other software) through the web:
[Link]
support/facilities/virtual-barn/overview/
• You can find Python 3.8 in the
‘Programming Software’ pool
After Installing • After installing, you will see
several options if you search
Python 3.8 for Python or perhaps
(These images are from a PC)
Python 3.8 in Windows
• Here is some documentation
about Python
– Probably you won’t need to
look at this, the COMP1021
notes and labs should be
enough
• Note - you will see this if you
install Python in your own
computer, but you probably
won’t see this in the CS labs
Using Python
• Let’s look at how
we can start using
Python
• There are two ways
we will look at now
COMP1021 Getting Started with Python Page 14
Using Python
• Both options give
you a shell
The Basic Idea of Using a Python Shell
2. The shell 1. User types
passes things one line
whatever at a time, in the
you type Python shell The User
to Python
Python
interpreter
[Link]
3. The Python
interpreter 4. The interpreter outputs
executes the results, which are
whatever is shown in the shell
given to it
Using a Python Shell –
Some Simple
Python Code
>>> is generated by the shell,
it means ‘this is where your input is shown’
Using the
IDLE Environment
• The IDLE environment is better
• One reason is that colours are automatically used,
which is sometimes very helpful for understanding
• We’ll see other useful features of IDLE soon,
especially in the lab work that we’ll do