Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lesson Objectives Aims Key Words

Similar presentations


Presentation on theme: "Lesson Objectives Aims Key Words"— Presentation transcript:

1 Lesson Objectives Aims Key Words
To recognise the different sections of 2.2 – Problem solving and programming To recap some basic programming theory from GCSE Computer Science (all that time ago) Key Words

2 2.2 Problem Solving and Programming
What do you need to get to know?

3 The Stuff You Should Remember
This will build on your GCSE knowledge –you need to be able to explain the basic constructs properly in addition to using them competently in your code. Programming, for all its modern advances still relies on the same basic principles. These are sequence, selection and iteration. The focus of 2.2.1a is sequence, iteration and branching (selection).

4 Sequence will always form part of your code.
2.2.1a – Sequence This is the easiest to understand; I should only be refreshing your memories right now! Code is executed sequentially – meaning that statements and functions are run one-after-the-other. Sequence will always form part of your code. Wheeeeeeee… These happy skiers are in sequence. Look how they follow each other!

5 Branching/Selection – Synonymous (that means they’re the same thing!)
2.2.1a – Branching Branching/Selection – Synonymous (that means they’re the same thing!) This specification prefers “Branching” so just remember to use the right word and you’re set. Branching is where code splits. The programme is interrupted and control is moved to another part of the programme. A happy branch. Look how it “branches” out.

6 2.2.1a – Branching Why on earth would you want your programme interrupted and going off in a different direction? Decisions to be made based on data Different outcomes These decisions that branch our code are based on Boolean expression. I.e. they are either true or false. They can only have these two possible outcomes. Don’t start asking your code philosophical questions in one go.

7 If flood depth is more than 10cm then wear flood pants
2.2.1a – Branching A logical example! If flood depth is more than 10cm then wear flood pants Is flood more than 10cm? True False Wear flood pants! Trousers The question is based on available data and can only be true or false.

8 2.2.1a – Branching In assembly language you will see BRA (always branch) and BRP (branch only if a condition is met). High-level languages follow the if, then, else. Structure for branching. An example if, then, else statement in VB.net

9 If statements can be nested within each other.
2.2.1a – Branching If statements can be nested within each other. It’s not always wise to nest IF after IF as your code will become horrible to follow. Rapido code time: Make a programme that checks if the user meets the following cascading criteria: Owns more than one llama, has at least 4 ceramic llama figurines, has no taste, is completely mad. A happy nest

10 Give another 2 mins in oven
2.2.1a – Iteration Iteration combines branching and sequencing to repeat statements and functions in our programmes. A happy little diagram… Mmm, cake Is my cake baked? True False Take it out of the oven Give another 2 mins in oven

11 In a flow chart our delicious cake problem would look something like..
2.2.1a – Iteration In a flow chart our delicious cake problem would look something like.. Start Mmm, cake Is my cake baked? Wait 2 minutes False True Take it out of the oven End

12 There are several ways to iterate your code…
2.2.1a – Iteration There are several ways to iterate your code… Do until: This will loop part of your code until something happens – these will run at least once before reacting to the conditions that you’ve set. An example do until loop in Visual Basic

13 2.2.1a – Iteration While: This loop will repeat until something changes. It differs from until by checking the criteria before starting the loop. A good example would be “While it’s raining, keep umbrella open”. If this was an until loop you’d open your brolly at first even if it isn’t raining. An example do while loop in Visual Basic

14 Brain the size of a planet and they ask me to climb stairs
2.2.1a – Iteration For: These loops are the easiest to understand – they repeat a fixed number of times. Either you will tell them explicitly how many times to run or they will get this figure from another part of the programme. Brain the size of a planet and they ask me to climb stairs This pointless staircase has 20 steps to the top – so we’d just have to tell Marvin to step 20 times.

15 2.2.1a – Iteration For: For loops are easy and will be a faithful but idiotic friend. Don’t rely on them too heavily or you’ll end up doing more work than you need to. Harold loves a loop An example for loop in VB. This loop counts backwards from 5.

16 2.2.1a – A quick challenge: The Governing Council for the Cat Fancy (it’s real!) wants you to create a registration programme: Asks for standard details (name, ) Asks how many cats they wish to register For each cat they should be asked for the cat’s name and if it is a purebred If it’s not a purebred the user is ineligible and the process must be restarted. Flowchart or pseudocode then code it (console application) A happy(?) purebred cat

17 Review/Success Criteria
You should know The basic constructs of code: Sequencing Branching Iteration (do/for/while) You should be able to confidently and independently use all three of these constructs to build effect and totally not rubbish programmes


Download ppt "Lesson Objectives Aims Key Words"

Similar presentations


Ads by Google