Upload
shawn-tyrell
View
219
Download
0
Embed Size (px)
Citation preview
8/11/2019 Programming for Teachers Presentation
1/31
Programming for Teachers [email protected]
Session Objectives
Understand the constructs that underpin most
programming languages.
Use these constructs to create simple computer
programs using Python.
8/11/2019 Programming for Teachers Presentation
2/31
Programming for Teachers [email protected]
About me
Alistair Surrall
CAS Master Teacher
BSc (Hons Computer Science
MA Technology and !ducation
Teaching "CT#Computing $or % years
&eader o$ &earning 'ith e' Technologies at TCS
@surrall
8/11/2019 Programming for Teachers Presentation
3/31
Programming for Teachers [email protected]
Hardware and SoftwareComputer systems are made up o$ t'o components
hard'are and so$t'are.
Hardware Software
8/11/2019 Programming for Teachers Presentation
4/31
Programming for Teachers [email protected]
What is programmingProgramming is the process o$ 'riting instructions to control
hard'are. Creating so$t'are.
8/11/2019 Programming for Teachers Presentation
5/31
Programming for Teachers [email protected]
Programming languagesThe instructions you 'rite need to )e in a language the
hard'are understands. There are loads o$ programminglanguages each 'ith their o'n idiosyncrasies.
8/11/2019 Programming for Teachers Presentation
6/31
Programming for Teachers [email protected]
Common constructs!early all programming languages pro*ide the same
constructs $or you to use to create your programs.Se+uencing
Selection"teration
Su),routines
-aria)les
ata Structures
8/11/2019 Programming for Teachers Presentation
7/31
Programming for Teachers [email protected]
Se"uencingSe"uencing means each instruction in the program is
e/ecuted once in the order it 'as gi*en.
8/11/2019 Programming for Teachers Presentation
8/31
Programming for Teachers [email protected]
Se"uencing
8/11/2019 Programming for Teachers Presentation
9/31
Programming for Teachers [email protected]
Selection
Selection means that the computer selects 'hich instruction
to e/ecute ne/t.
This can )e )ased on a condition in the program or on user
input.
8/11/2019 Programming for Teachers Presentation
10/31
Programming for Teachers [email protected]
Selection
8/11/2019 Programming for Teachers Presentation
11/31
Programming for Teachers [email protected]
Selection# $% &'S&
8/11/2019 Programming for Teachers Presentation
12/31
Programming for Teachers [email protected]
Selection# $% ( &'S& $%
8/11/2019 Programming for Teachers Presentation
13/31
Programming for Teachers [email protected]
$teration
$teration0ust means repetition.
There are many times 'hen you $ind yoursel$ gi*ing the same
instruction repeatedly.
"teration is used to tell the computer1s hard'are to $ollo' the
same instruction a num)er o$ times.
Programming languages use 'oops to repeat an instruction.
8/11/2019 Programming for Teachers Presentation
14/31
Programming for Teachers [email protected]
Se"uence
8/11/2019 Programming for Teachers Presentation
15/31
Programming for Teachers [email protected]
$teration
8/11/2019 Programming for Teachers Presentation
16/31
Programming for Teachers [email protected]
$teration# %O) loops
%O) 'oops repeat an instruction a set num)er o$ times.
8/11/2019 Programming for Teachers Presentation
17/31
Programming for Teachers [email protected]
$teration# WH$'& loops
WH$'& 'oops repeat an instruction until a condition is met .
8/11/2019 Programming for Teachers Presentation
18/31
Programming for Teachers [email protected]
Sub*routines
2hen a se+uence o$ instructions is going to )e repeated a
num)er o$ times at di$$erent points in the same program it iso$ten use$ul to put them in a separate su),routine.
The su),routine can then )e called at the rele*ant points inthe program.
2hen programming a su),routine can )e de$ined as +a namedbloc, of code that carries out a specific tas,-.
8/11/2019 Programming for Teachers Presentation
19/31
Programming for Teachers [email protected]
Sub*routines
8/11/2019 Programming for Teachers Presentation
20/31
Programming for Teachers [email protected]
Sub*routines
8/11/2019 Programming for Teachers Presentation
21/31
Programming for Teachers [email protected]
Sub*routines# %unctions
A %unction is a su),routine that returns a *alue.
8/11/2019 Programming for Teachers Presentation
22/31
Programming for Teachers [email protected]
Sub*routines# ProceduresProcedures are su),routines that don-t return a *alue. They
can display in$ormation to a user )ut they don1t return any
in$ormation )ack to the main program.
8/11/2019 Programming for Teachers Presentation
23/31
Programming for Teachers [email protected]
.ariablesA variable is a named location in the computer1s memory that
a programmer can use to store 3 manipulate data 'hilst the
program is running.
8/11/2019 Programming for Teachers Presentation
24/31
8/11/2019 Programming for Teachers Presentation
25/31
8/11/2019 Programming for Teachers Presentation
26/31
8/11/2019 Programming for Teachers Presentation
27/31
Programming for Teachers [email protected]
/ata Structuresata Structures are a 'ay o$ storing or organising in$ormation
in your program so that it can )e used e$$iciently.
The most common type o$ data structure is called an array.
Arrays are 0ust a set o$ *aria)les o$ the same type held in ro's
and columns.
i f h ll h h l k
8/11/2019 Programming for Teachers Presentation
28/31
Programming for Teachers [email protected]
/ata Structures# Arrays
P i f T h ll@ h h l k
8/11/2019 Programming for Teachers Presentation
29/31
Programming for Teachers [email protected]
/ata Structures# &lements!ach *aria)le in an array is called an element. !ach element
can )e accessed )y re$erencing it1s location in the array.
arrNames[3]
otice that the elements always )egin at 5.
P i f T h ll@th h l k
8/11/2019 Programming for Teachers Presentation
30/31
Programming for Teachers [email protected]
0uestions
Activities
P i f T h ll@th h l k
8/11/2019 Programming for Teachers Presentation
31/31
Programming for Teachers [email protected]
Pygame