Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading content…
Loading…
Transcript

TASK

In practice

FOR loops

Count controlled loop

Code inside is repeated a fixed number of times

Setting a loop

Sequence

We can set the values of the loop using variables

We tell the computer how many times we want to repeat - initial value, end value, step value

Program Flow

Programming basic

Instructions executed in the correct order - if not we don't get the result we expect!

All about controlling what parts of your code get executed and which parts don't!

Imagine tying your laces before you have put you shoes on!

If no step value is given, we step by 1

Give it a go

Iteration Statements

Lesson Objectives

There are three ways to control program flow - selection, sequence and iteration!

There are 4 iteration (loop) statements that you need to know about.

  • Repeats loops
  • While Loops
  • Do while loops
  • For loops

  • To understand the concepts of selection
  • To understand the concept of iteration
  • To understand sequence in programming.

Plenary

Practice

EXT - add elif options to deal with scores of 900, 800 and 700

IF statements

In 60 seconds, explain to the person sitting next to you the difference between all of the loops we have learned about today - no looking at your revision resource!

IF a condition is true, then perform this action

ELSE perform that action

Revise, Recap, Review

Nested IF statements

IF ELSE gives us two options,adding ELIF gives us

  • Putting one IF statement inside another one.
  • Allow you to check more conditions once you have established that the previous condition is true.

options!

3 data types and what they are used for

Imagine you had a voting system

Pros and Cons

+ Neater than big elif statements

+ Easier to maintain

- Only check the value of one variable unlike an IF

- Not all languages support the use of them

Variable

What to do in that case

Switch Case

Instead of checking if something is true or false, a switch case checks if a variable has a specific value

2 disadvantages of a merge sort

1 explanation of the fetch, decode, execute cycle

Different actions for different values on the same variable

A repeat loop

Condition controlled loops

Controlled by a condition at the end of the loop

Always runs code AT LEAST ONCE

In this loop, we repeat whilst the condition is FALSE

DO WHILE

Rather than repeat a set number of times, these loops repeat until a condition is met

TASK

Also controlled by condition at the end

DO WHILE true

Also always runs the code at least once

Create a set of flashcards/revision poster/mind map to explain FOR, REPEAT, WHILE and DO WHILE loops

WHILE

Repeat loops

While Loops

Do while Loops

Condition comes first

If condition is false to begin with it won't execute the conditional code at all

Keep going while the condition is true

These are core concepts of programming and it is important that you get them right!

Selection

If statements and Switch Case statements enable us to use selection

They do similar things but they are used for different purposes.

Paper 2 - 2.2: Programming techniques L2

Learn more about creating dynamic, engaging presentations with Prezi