You are on page 1of 29

Introduction to Programming

CPT120

Chapter 1

Overview of Unit

In this unit, you will learn the fundamentals of programming that are found in popular programming languages.

We use a programming language and an environment called JES (Jython Environment for Students), which is based
on a popular programming language called Python.

The unit is very hands-on. You will learn and practice programming fundamentals through the manipulation of digital
images.

You will use the units Blackboard (via myRMIT) each week to do the following:

1. Read the lecture slides and then watch the lecture slide commentary (videos)

2. Participate in the discussion forums Ask (or answer) general questions on topics covered

3. Attempt the weekly tutorial exercises and submit your solutions (textbook is required)

4. Work on parts of the current assignment (when released) and ask any general questions in assignment forum

5. Attend the weekly tutorial chat session (your instructor will discuss solutions for the previous week)
In addition to the above, you will also need to submit assignments as per the due dates and towards the end of the
study period you will need to prepare for the final exam.

Assessments:

Hurdle A (50 marks)


1. Weekly tutorials (due end of each week): 18 marks total
2. Assignment 1 (due end of week 6): 16 marks
3. Assignment 2 (due end of week 12): 16 marks

Hurdle B (50 marks)


1. End of study period 2 hour exam

School of Computer Science & IT

Staff and Contacts

CPT120 Coordinating Instructor: Mr. Gayan Wijesinghe

CPT120 Instructor: Dr. Robert McQuillan

robert.mcquillan@rmit.edu.au
Weekly online (live) tutorial chats and discussion forums

RMIT Technical Services Group (a.k.a. ITS)

gayan.wijesinghe@rmit.edu.au
Administration and coordination related matters within the unit
Study materials, assignment and exam design
Weekly online (live) tutorial chats and discussion forums

www.rmit.edu.au/its (good) or itservicesdesk@rmit.edu.au (faster) or 03-9925-8888 (fastest)


All technical issues and queries relating (but not limited) to student accounts, usernames,
passwords, Blackboard and Collaborate Chat systems, lecture videos, etc.

RMIT OUA Administration: Miss Maree Graham

ouacsit@rmit.edu.au
Processes special consideration and extensions
Queries relating to your OUA degree/programme, struture, etc.

School of Computer Science & IT

Resources

You will need to obtain a copy of the prescribed textbook:


Title: Introduction to Computing and Programming in Python: A Multimedia Approach
Authors: Mark J. Guzdial and Barbara Ericson
Edition: 3
ISBN10: 0132923513
ISBN13: 9780132923514

These slides are a commentary on the text book.

All other learning/unit materials will be made available on or via the Blackboard

School of Computer Science & IT

A brief history of this unit


In the mid-2000s, a boom in digital media (communications) and games
graphics design (art) education meant that a lot of non-IT students
needed to learn programming.
Introduction To Programming was introduced as an on-campus unit for
undergraduate students with no prior experience in programming. It still
is and it was also successfully adapted for online learning (OUA) several
years ago.

Study materials have been specifically tailored to teach programming in


a new way. Not the usual Java, Visual Basic, C++, Haskell, C, etc.
This unit is a result of over 6 years of research, evolution and experience
in teaching programming to students who come from non-IT
backgrounds.
This is the best version by far.
School of Computer Science & IT

The Story
What is computer science about?
What computers really understand, and where Programming Languages
fit in
Media Computation: Why digitise media?
How can it possibly work?

Computer Science for Everyone


Its about communications and process

School of Computer Science & IT

Whats computation good for


Computer science is the study of recipes
Computer scientists study
How the recipes are written (algorithms, software
engineering)
The units used in the recipes (data structures, databases)
What can recipes be written for (systems, intelligent
systems, theory)
How well the recipes work (human-computer interfaces)

School of Computer Science & IT

Specialised Recipes
Some people specialise in crepes or barbecue
Computer scientists can also specialise on special
kinds of recipes
Recipes that create pictures, sounds, movies, animations
(graphics, computer music)

Still others look at emergent properties of


computer recipes
What happens when lots of recipes talk to one another
(networking, non-linear systems)

School of Computer Science & IT

Key concept:
The COMPUTER follows the recipe!
Programming is putting together a sequence of
instructions to get the computer to do something we want.
Make it as hard, tedious, complex as you want!

Crank through a million genomes? No problem!


Find one person in a 30,000 campus? Yawn!

Process a million dots on the screen or a bazillion sound


samples?
Thats media computation

School of Computer Science & IT

What computers understand


Its not really multimedia at all.
Its unimedia (said Nicholas Negroponte, founder of MIT Media Lab)
Everything is 0s and 1s

Computers are exceedingly stupid


The only data they understand is 0s and 1s
They can only do the most simple things with those 0s and 1s

Move this value here


Add, multiply, subtract, divide these values
Compare these values, and if one is less than the other, go follow
this step rather than that one.

Done fast enough, those simple things can be amazing.

School of Computer Science & IT

10

Programming Languages
Different programming languages are different
ways (encodings) that turn into (same/similar)
commands for the computer

School of Computer Science & IT

11

A word about Jython

Jython is Python

Python is a very popular programming language

Games: E.g. Battlefield 2, Civilization 4, etc.

Graphics: E.g. Industrial Light & Magic, Walt Disney, Blender 3D software, etc.

Science: E.g. US National Oceanic and Atmospheric Administration, NASA, etc.

Electronics: E.g. Integrated Circuit (IC) design

Software Development: E.g. Silicon Graphics Inc. (SGI), Red Hat, Nokia, etc.

Education: E.g. many

Business Software: E.g. IBM, AMS Inc., etc.

Government: E.g. CIA website, etc.

Web development: E.g. Google, Yahoo!, etc.

[Source: python.org]

Python is implemented in C.

Jython is the same language implemented in Java.


Is the pizza different if a different company makes the flour? If so, not by much.

JES (Jython Environment for Students) is an integrated developing environment (IDE)


that lets you easily write, run and maintain Jython programs.

School of Computer Science & IT

12

Key Concept: Encodings


We can interpret the 0s
and 1s in computer
memory any way we
want.

We can treat them as numbers.


We can encode information in those
numbers

Even the notion that


the computer
understands numbers
is an interpretation

We encode the voltages on wires as


0s and 1s,
eight of these defining a byte
Which we can, in turn, interpret as a
decimal number
13

How a computer works


The part that does the adding
and comparing is the Central
Processing Unit (CPU).
The CPU talks to the memory
Think of it as a sequence millions of
mailboxes, each one byte in size, each of
which has a numeric address

A hard disk might provide 125


times or more storage than
memory (1TB versus 8GB), but
is much slower.
The display is the monitor or
LCD"

14

Layer the encodings


as deep as you want
One encoding, ASCII, defines an A as 65
If theres a byte with a 65 in it, and we decide that its a
string, POOF! Its an A!

We can string together lots of these numbers


together to make usable text
77, 97, 114, 107 is Mark
60, 97, 32, 104, 114, 101, 102, 61 is
<a href= (HTML)

School of Computer Science & IT

15

What do we mean by layered encodings?


A number is just a number is just a number
If you have to treat it as a letter, theres a piece of
software that does it
For example, that associates 65 with the graphical representation for A

If you have to treat it as part of an HTML


document, theres a piece of software that does it
That understands that <A HREF= is the beginning of a link

That part that knows HTML communicates with


the part that knows that 65 is an A

School of Computer Science & IT

16

Multimedia is unimedia
But that same byte with a 65 in it might be
interpreted as
A very small piece of sound (e.g., 1/44100-th of a second)
The amount of redness in a single dot in a larger picture
The amount of redness in a single dot in a larger picture
which is a single frame in a full-length motion picture

School of Computer Science & IT

17

Software (recipes) defines and manipulates


encodings
Computer programs manage all these layers
How do you decide what a number should mean, and how you
should organise your numbers to represent all the data you want?
Thats data structures

If that sounds like a lot of data, it is


To represent all the dots on your screen:
1920x1080 (Full HD) RGB pixels
1920 x 1080 x 3 = 6,220,800 colour values that a 1 byte each
Each second of sound on a CD is encoded at 44100 samples a
second, 16-bits (2 bytes) per sample, two channels for left and right
stereo. How many bytes per second?

School of Computer Science & IT

18

Thank goodness for Moores Law


Gordon Moore, one of the founders of Intel, made
the claim that (essentially) computer power
doubles for the same dollar every 18 months.
This has held true for over 30 years.
Go ahead! Make your computer do the same thing
to everyone of 3 million dots on your screen! It
doesnt care! And it wont take much time either!

School of Computer Science & IT

19

Why digitise media?


Digitising media is encoding media into numbers
Real media is analogue (continuous).
To digitise it, we break it into parts where we cant
perceive the parts.

By converting them, we can more easily


manipulate them, store them, transmit them
without error, etc.

School of Computer Science & IT

20

How can it work to


digitise media?
Why does it work that we can break media into
pieces and we dont perceive the breaks?
We can only do it because human perception is
limited.
We dont see the dots in the pictures, or the gaps in the
sounds.

We can make this happen because we know about


physics (science of the physical world) and
psychophysics (psychology of how we perceive the
physical world)

School of Computer Science & IT

21

Why should you need to study


recipes?
To understand better the recipe-way of thinking
Its influencing everything, from computational science to bioinformatics
Eventually, its going to become part of everyones notion of a liberal
education
Thats the process argument
BTW, to work with and manage computer scientists

ANDto communicate!
Writers, marketers, producers communicate through computation

Well take these in opposite order

School of Computer Science & IT

22

Computation for Communication

All media are going digital


Digital media are manipulated with
software
You are limited in your communication
by what your software allows
What if you want to say something that Microsoft or
Adobe or Apple doesnt let you say?

School of Computer Science & IT

23

Programming is a communications skill


If you want to say something that your tools dont allow,
program it yourself

If you want to understand what your tools can or cannot


do, you need to understand what the programs are doing
If you care about preparing media for the Web, for
marketing, for print, for broadcast then its worth your
while to understand how the media are and can be
manipulated.

Knowledge is Power,
Knowing how media work is powerful and freeing

School of Computer Science & IT

24

Were not going to replace PhotoShop


Adobe Photoshop, GarageBand, ProAudio Tools,
ImageMagick and the GIMP, and Java and Visual
Basic
But if you know what these things are doing, you
have something that can help you learn new tools

School of Computer Science & IT

25

Knowing about programming is knowing about


process
Alan Perlis
One of the founders of computer science
Argued in 1961 that Computer Science should be part of a
liberal education: Everyone should learn to program.
Perhaps computing is more critical to a liberal
education than Calculus
Calculus is about rates, and thats important to many.
Computer science is about process, and thats
important to everyone.
Automating process
changes everything.

School of Computer Science & IT

26

A Recipe is a Statement of Process


A recipe defines how something is done
In a programming language that defines how the recipe
is written

When you learn the recipe that implements a


Photoshop filter, you learn how Photoshop does
what it does.
And that is powerful.

School of Computer Science & IT

27

Finally: Programming is about


Communicating Process

A program is the most concise


statement possible to
communicate a process
Thats why its important to scientists and others who
want to specify how to do something understandably in
as few words as possible

School of Computer Science & IT

28

JES
JES v4.3 must be used.
Download from: Blackboard -> Course Documents -> Software to
download
Please do the tutorial exercises (Blackboard->Course Documents>Week 1, etc.) and submit them

School of Computer Science & IT

29

You might also like