Lesson Objectives Aims Key Words

Slides:



Advertisements
Similar presentations
Project on VB Control Structures
Advertisements

Selection (decision) control structure Learning objective
Lesson 5 - Decision Structure By: Dan Lunney
 Control structures  Algorithm & flowchart  If statements  While statements.
Problem Solving Chapter 2. What is an algorithm? n A solution to a problem that is: –Precise –Effective –Terminating.
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
True or False Unit 3 Lesson 7 Building Blocks of Decision Making With Additions & Modifications by Mr. Dave Clausen True or False.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Chapter 7 Problem Solving with Loops
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
3.1.3 Program Flow control Structured programming – SELECTION in greater detail.
Algorithms and Pseudocode
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
PHY 107 – Programming For Science. Today’s Goal  How to use while & do / while loops in code  Know & explain when use of either loop preferable  Understand.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Lab 4: Loops and Iteration Graham Northup
CMSC201 Computer Science I for Majors Lecture 07 – While Loops
The Little man computer
Learning outcomes 5 Developing Code – Using Flowcharts
Lesson Objectives Aims Key Words
Lesson Objectives Aims Key Words
A451 Theory – 7 Programming 7A, B - Algorithms.
The switch Statement, and Introduction to Looping
Python: Control Structures
Creativity in Algorithms
Understand Problem Solving Tools to Design Programming Solutions
Teaching design techniques to design efficient solutions to problems
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
Chapter 5: Repetition Structures
Expressions and Control Flow in JavaScript
Lesson 9: "if-else-if" and Conditional Logic
Web Programming– UFCFB Lecture 16
Microsoft Visual Basic 2005 BASICS
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Print slides for students reference
LESSON 11 – WHILE LOOPS UNIT 5 – 1/10/17.
Learning to Program in Python
Creativity in Algorithms
Problem-Solving and Control Structures By Faith Brenner
Outline Altering flow of control Boolean expressions
While Loops and If-Else Structures
Lesson 2 Programming constructs – Algorithms – Scratch – Variables Intro.
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Chapter 6: Repetition Structures
Chapter 5: Repetition Structures
Understanding the Three Basic Structures
Topic 1: Problem Solving
Computers in the real world Objectives
Design and Implementation
Three Special Structures – Case, Do While, and Do Until
Algorithm and Ambiguity
Computer Science Core Concepts
Problem-Solving and Control Structures By Faith Brenner
ICT Programming Lesson 3:
if-else Structures Principles of Engineering
Flowcharts and Pseudo Code
ICT Gaming Lesson 2.
Using Decision Structures
Starter....
Welcome back! October 11, 2018.
WJEC GCSE Computer Science
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
How to allow the program to know when to stop a loop.
Presentation transcript:

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 Problem Solving and Programming What do you need to get to know?

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).

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!

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.

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.

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.

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

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

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

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

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

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

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.

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.

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, email) 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

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