Documente Academic
Documente Profesional
Documente Cultură
Programming
Preparation
Dr.
Erin
Roehrer
Lecture
Objectives
CompuQng
Tools
and
Terms
Why
program?
What
is
a
programming
language?
Programming
Tools
and
Terms
What
is
Python?
Using
Python
Software
programs and data
a program is a series of instructions
data is what the program instructs the computer to
Central!
Processing!
Unit!
Hard Disk!
Main!
Memory!
USB Disk!
DVD/CD!
Secondary
memory
devices
provide
long-term
storage
Central!
Processing!
Unit!
Hard Disk!
I/O
(Input
Output)
devices
for
communicaQon
with
CPU
Main!
Memory!
USB Disk!
DVD/CD!
fetch!
execute!
Carry
out
the
instrucQon
-
access
and
modify
data
if
instructed
to
decode!
Determine
what
the
instrucQon
is
10
Software
Categories
Operating System
Applications
UlQmately,
any
applicaQon
we
create
will
interact
converted to 0s and 1s
known as bytes
13
Memory
9278
9279
9280
9281
9282
9283
9284
9285
9286
14
Storing
Information
9278!
9279!
9280!
9281!
9282!
9283!
9284!
9285!
9286!
10011010!
15
Storing
Information
9278!
9279!
9280!
9281!
9282!
9283!
9284!
9285!
9286!
10011010!
firstName!
rstName
is
called
a
variable.
16
Storing
Information
9278!
9279!
9280!
9281!
9282!
9283!
9284!
9285!
9286!
10011010!
firstName (String)!
rstName
is
a
variable
of
type
String.
Why
Program?
Computers
are
very
fast,
but
stupid
machines
Things
that
humans
might
nd
hard,
or
boring,
Recording
Data
Analysing
Data
Finding
Pa[erns
Plobng
Data
AutomaQng
Tasks
Comparing
Data
MulQ-Tasking
Image
Processing
Why
Program?
As such computer programs are used not only in our
leisure time with games and social networks, but also in:
Biology, Chemistry, Physics, Bioinformatics
Commerce, Health, Industry
Sociology, Law, Media Production
Why Program?
file
A program usually consists of one or more classes; Classes
consist of one or more functions; Functions consist of one or
more statements
Machine
Languages
Machine
Language
A
computers
naQve
language
a
set
of
primiQve
instrucQons.
In
the
form
of
binary
code
E.g.:
1101101010011010
Assembly
Languages
Programming
in
Machine
Language
is
tedious!
Assembly
Language
was
created
to
make
life
a
bit
easier.
Add 2, 3, result
High-Level
Language
English-like
Easier
to
learn
and
use
than
assembly
language
InstrucQons
in
high-level
language
are
called
statements
High-Level
Languages
Pascal
C
Visual
Basic
Java
C++
C#
Python
language (syntax)
Structure
of
a
program
Think
of
wriQng
a
le[er
or
email:
A
wri[en
language
species
words
and
punctuaQon
that
can
be
used
to
write
a
le[er
rules
to
form
understandable
and
recognisable
statements
whitespace
doesnt
change
the
meaning
of
the
le[er
sentences
Dear Mummy,
I am writing because I cannot find my teddy. It was
sitting next to my beer, and I can no longer find it.
If you have stolen it, could you please return it? The
other guys in the regiment all have theirs Thanks.
Sincerely,
your loving son Mikey.
Components
of
a
program
IdenQers
Rules
le[ers,
numbers,
and
underscore
(_)
only
and
cannot
be
the
same
as
reserved
words
ConvenQons
start
with
a
le[er,
examples
later
Comments
#
rest
of
line
is
comment
'''
everything
is
comment
up
to
'''
White
Space
(space,
tab,
blank
lines)
Blocks
must
be
indented
evenly
Statements
end
with
a
new
line
(<Enter>
key)
Reserved
words
31
Structure
of
a
Program
# declarations
# executable statements
block !
containing!
code
# and/or comments
Some languages
Use syntax to collect statements into blocks, e.g. {} but
Statements
print("Hello World!")
print("Programming is fun!")
Design
the
program
Write
the
code
Correct
syntax
errors
Test
the
program
Correct
logic
errors
What
is
Python?
Developed
by
Guido
van
Rossum
in
1991.
Python
is
a
high-level
general-purpose
programming
language
that
can
be
applied
to
many
dierent
classes
of
problems.
With
Python,
students
can
be
quickly
introduced
to
basic
concepts
required
for
successful
programming.
Easy
to
read
Less
development
Qme
(shorter
code)
Reduced
learning
Qme
What
is
Python?
Complied
Directly
converted
to
machine
code
Directly
converted
to
byte
code
Indirectly
converted
to
byte
code
C, C++
Java, C#
Python
Interpreted
Purely
Interpreted
Shell, Perl
else
except
exec
finally
for
from
global
if
import
in
is
lambda
not
or
pass
print
raise
return
try
while
with
yield
errors)
40
PRINT("Hello World!")
41
Using
Python
We
want
to
launch
the
IDLE
Python
2.7
Python
2
vs
Python
3
Python
3
is
a
newer
version,
but
it
is
not
backward
compaQble
with
Python
2.
That
means
if
you
write
a
program
using
Python
2,
it
may
not
work
on
Python
3.
Creating a le
revision
Uses include
Exam this is the ONLY material that you may take into
the examination
Resources
Unit MyLO Web site
lecture recordings
tutorial and activity work
assessment information
Python Web sites
http://docs.python.org/2/tutorial/
http://wiki.python.org/moni/BeginnersGuide/
Programmers
http://www.learnpython.org