Programming for Teachers

Post on 10-Oct-2015

6 views 0 download

Tags:

description

presentation

Transcript of Programming for Teachers

Slide 1

Session ObjectivesUnderstand the constructs that underpin most programming languages.Use these constructs to create simple computer programs using Python.

Programming for Teachers asurrall@thecooperschool.co.uk1About meAlistair Surrall CAS Master TeacherBSc (Hons) Computer ScienceMA Technology and EducationTeaching ICT\Computing for 5 yearsLeader of Learning with New Technologies at TCSasurrall@thecooperschool.co.uk

@surrall

Programming for Teachers asurrall@thecooperschool.co.uk2Hardware and SoftwareComputer systems are made up of two components hardware and software.

HardwareSoftwareProgramming for Teachers asurrall@thecooperschool.co.uk3

What is programming?Programming is the process of writing instructions to control hardware. Creating software.

Programming for Teachers asurrall@thecooperschool.co.uk4Programming languagesThe instructions you write need to be in a language the hardware understands. There are loads of programming languages each with their own idiosyncrasies.

Programming for Teachers asurrall@thecooperschool.co.uk5Common constructsNearly all programming languages provide the same constructs for you to use to create your programs.SequencingSelectionIterationSub-routinesVariablesData Structures

Programming for Teachers asurrall@thecooperschool.co.uk6SequencingSequencing means each instruction in the program is executed once in the order it was given.

Programming for Teachers asurrall@thecooperschool.co.uk7Sequencing

Programming for Teachers asurrall@thecooperschool.co.uk8SelectionSelection means that the computer selects which instruction to execute next.

This can be based on a condition in the program or on user input.Programming for Teachers asurrall@thecooperschool.co.uk9Selection

Programming for Teachers asurrall@thecooperschool.co.uk10Selection: IF ELSE

Programming for Teachers asurrall@thecooperschool.co.uk11

Selection: IF , ELSE IFProgramming for Teachers asurrall@thecooperschool.co.uk12IterationIteration just means repetition.

There are many times when you find yourself giving the same instruction repeatedly.

Iteration is used to tell the computers hardware to follow the same instruction a number of times.

Programming languages use Loops to repeat an instruction.Programming for Teachers asurrall@thecooperschool.co.uk13Sequence

Programming for Teachers asurrall@thecooperschool.co.uk14Iteration

Programming for Teachers asurrall@thecooperschool.co.uk15Iteration: FOR loops

FOR Loops repeat an instruction a set number of times.Programming for Teachers asurrall@thecooperschool.co.uk16Iteration: WHILE loopsWHILE Loops repeat an instruction until a condition is met .

Programming for Teachers asurrall@thecooperschool.co.uk17Sub-routinesWhen a sequence of instructions is going to be repeated a number of times at different points in the same program it is often useful to put them in a separate sub-routine.

The sub-routine can then be called at the relevant points in the program.

When programming a sub-routine can be defined as a named block of code that carries out a specific task. Programming for Teachers asurrall@thecooperschool.co.uk18Sub-routines

Programming for Teachers asurrall@thecooperschool.co.uk19Sub-routines

Programming for Teachers asurrall@thecooperschool.co.uk20Sub-routines: FunctionsA Function is a sub-routine that returns a value.

Programming for Teachers asurrall@thecooperschool.co.uk21Sub-routines: ProceduresProcedures are sub-routines that dont return a value. They can display information to a user but they dont return any information back to the main program.

Programming for Teachers asurrall@thecooperschool.co.uk22VariablesA variable is a named location in the computers memory that a programmer can use to store & manipulate data whilst the program is running.

Programming for Teachers asurrall@thecooperschool.co.uk23Variables

Programming for Teachers asurrall@thecooperschool.co.uk24Data typesWhen you declare your variable by giving it its name the computer will want to know what type of data you are going to store in it Text, Number, Character etc.

Programming for Teachers asurrall@thecooperschool.co.uk25Data StructuresData Structures are a way of storing or organising information in your program so that it can be used efficiently. The most common type of data structure is called an array. Arrays are just a set of variables of the same type held in rows and columns.

Programming for Teachers asurrall@thecooperschool.co.uk26Data StructuresData Structures are a way of storing or organising information in your program so that it can be used efficiently. The most common type of data structure is called an array. Arrays are just a set of variables of the same type held in rows and columns. Programming for Teachers asurrall@thecooperschool.co.uk27Data Structures: Arrays

Programming for Teachers asurrall@thecooperschool.co.uk28Data Structures: Elements

Each variable in an array is called an element. Each element can be accessed by referencing its location in the array.

arrNames[3]

Notice that the elements always begin at 0.

Programming for Teachers asurrall@thecooperschool.co.uk29Questions?ActivitiesProgramming for Teachers asurrall@thecooperschool.co.uk30Pygame

Programming for Teachers asurrall@thecooperschool.co.uk31