Programming for Teachers

download Programming for Teachers

of 31

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 [email protected] meAlistair Surrall CAS Master TeacherBSc (Hons) Computer ScienceMA Technology and EducationTeaching ICT\Computing for 5 yearsLeader of Learning with New Technologies at [email protected]

@surrall

Programming for Teachers [email protected] and SoftwareComputer systems are made up of two components hardware and software.

HardwareSoftwareProgramming for Teachers [email protected]

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

Programming for Teachers [email protected] 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 [email protected] constructsNearly all programming languages provide the same constructs for you to use to create your programs.SequencingSelectionIterationSub-routinesVariablesData Structures

Programming for Teachers [email protected] means each instruction in the program is executed once in the order it was given.

Programming for Teachers [email protected]

Programming for Teachers [email protected] 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 [email protected]

Programming for Teachers [email protected]: IF ELSE

Programming for Teachers [email protected]

Selection: IF , ELSE IFProgramming for Teachers [email protected] 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 [email protected]

Programming for Teachers [email protected]

Programming for Teachers [email protected]: FOR loops

FOR Loops repeat an instruction a set number of times.Programming for Teachers [email protected]: WHILE loopsWHILE Loops repeat an instruction until a condition is met .

Programming for Teachers [email protected] 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 [email protected]

Programming for Teachers [email protected]

Programming for Teachers [email protected]: FunctionsA Function is a sub-routine that returns a value.

Programming for Teachers [email protected]: 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 [email protected] 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 [email protected]

Programming for Teachers [email protected] 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 [email protected] 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 [email protected] 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 [email protected] Structures: Arrays

Programming for Teachers [email protected] 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 [email protected]?ActivitiesProgramming for Teachers [email protected]

Programming for Teachers [email protected]