PROGRAMMING In Lesson 5. RECAP  Complete the starter activity.

Slides:



Advertisements
Similar presentations
Solving Problems with Repetition. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C# program Correctly.
Advertisements

© Copyright 2012 by Pearson Education, Inc. All Rights Reserved.1 Chapter 5 Loops.
Programming in python Lesson 2.
Μαθαίνοντας Python [Κ4] ‘Guess the Number’
Chapter 4 Loops Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
CS 106 Introduction to Computer Science I 02 / 11 / 2008 Instructor: Michael Eckmann.
Lecture 12 Another loop for repetition The while loop construct © 2007 Daniel Valentine. All rights reserved. Published by Elsevier.
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
An Introduction to Textual Programming
Scientific Notation.
1 Copyright (C) 2008 by Dennis A. Fairclough all rights reserved.
Outlines Chapter 3 –Chapter 3 – Loops & Revision –Loops while do … while – revision 1.
Python Programming Using Variables and input. Objectives We’re learning to make use of if statements to enable code to ask questions. Outcomes Build an.
General Programming Introduction to Computing Science and Programming I.
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
Chapter 4 Loops Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved
Liang, Introduction to Programming with C++, Second Edition, (c) 2010 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
Module 3 Fraser High School. Module 3 – Loops and Booleans import statements - random use the random.randint() function use while loop write conditional.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Fundamentals of Python: First Programs
Python Programming Using Variables and input. Objectives We’re learning to build functions and to use inputs and outputs. Outcomes Build a function Use.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
30/10/ Iteration Loops Do While (condition is true) … Loop.
1 while loops. 2 Definite loops definite loop: A loop that executes a known number of times.  The for loops we have seen so far are definite loops. We.
Adding Integers. Zero Pair = 0 Why it works… __________ Property says you can add or subtract zero without changing the value of an expression.
PROGRAMMING In Lesson 2. STARTER ACTIVITY Complete the starter activity in your python folder – lesson 2 Now we will see how you got on and update your.
Logic Our programs will have to make decisions on what to do next –we refer to the decision making aspect as logic Logic goes beyond simple if and if-else.
 There are times when you will want blocks to repeat. Instead of duplicating blocks and ending up with a long script that might be confusing, there.
+ Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Chapter 5: Looping.
22/11/ Selection If selection construct.
Chapter 3: Branching and Program Flow CSCI-UA 0002 – Introduction to Computer Programming Mr. Joel Kemp.
Decision Structures and Boolean Variables. Sequence Structures Thus far, we’ve been programming “sequence structures” Thus far, we’ve been programming.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
Iteration. Iteration: Review  If you wanted to display all the numbers from 1 to 1000, you wouldn’t want to do this, would you? Start display 1 display.
GCSE Computing: Programming GCSE Programming Remembering Python.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 4 Loops.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 5 Looping.
Python Lesson 2.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
Algorithms and Pseudocode
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
BO65: PROGRAMMING ITERATION 1. Starter  Write down what you think the code below outputs on screen: Dim intCounter as integer intCounter = 0 Do while.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Solving Problems with Repetition Version 1.0. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C#
PROGRAMMING In Lesson 6. RECAP  Discuss with the person next to you...  what you have enjoyed about python programming  What you have found difficult.
KEY STAGE 3 ICT Databases – Lesson 2. Recap of keywords – Task 2A In your workbooks from last lesson What is a database? A DATABASE is a collection of.
26/06/ Iteration Loops For … To … Next. 226/06/2016 Learning Objectives Define a program loop. State when a loop will end. State when the For.
Loops Brent M. Dingle Texas A&M University Chapter 6 – Section 6.3 Multiway Branches (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Introduction to Loop. Introduction to Loops: The while Loop Loop: part of program that may execute > 1 time (i.e., it repeats) while loop format: while.
Starter What does the following code do?
Whatcha doin'? Aims: To start using Python. To understand loops.
3.1 Fundamentals of algorithms
Chapter 5: Looping Starting Out with C++ Early Objects Seventh Edition
Do it now activity Green pen activity in books.
Iterations Programming Condition Controlled Loops (WHILE Loop)
Logical Operators and While Loops
Learning to Program in Python
Programming In Lesson 3.
COMPUTER PROGRAMMING PYTHON
Do While (condition is true) … Loop
IST256 : Applications Programming for Information Systems
Chapter 5 Loops.
3.1 Iteration Loops For … To … Next 18/01/2019.
Python programming exercise
Logical Operators and While Loops
Programming In Lesson 4.
Presentation transcript:

PROGRAMMING In Lesson 5

RECAP  Complete the starter activity

OBJECTIVES  Understand how to use looping statement (while)  Understand to use the break statement  Understand the development process of flow charts to comments to code O UTCOMES  All-Level 4 written code using while - with help developed programs using pseudo code  Most-Level 5Be able to write a these with little help.  Some-Level 6Independently write these and adapt them and complete the extension tasks.

LOOPS  You might remember this code from your truth table of last lesson. It is part of the function that got the user input.  It uses a while statement to keep asking the user to input a value until it is one of the required values.

WHILE STATEMENT while expression : statement 1 statement 2 statement 3 Statements are executed while the expression is true Notice the indentation – this defines the statements that are in the while statement Don’t forget the full colon

WRITE A LOOPY PROGRAM – PSEUDO CODE Write a program that asks the user for a number and counts down to 1 displaying each number as it goes. a=int(a) – converts number a to an integer You have the rest of the knowledge. Extension: Get you program to calculate the factorial of the number. Hint: factorial of 4 is 4 * 3 * 2 * 1. start Ask user for a number Convert to integer Display numberSubtract one Is number > 0 Yes end No Write the pseudo code for the program. We will then write the program comments from this pseudo code We will then fill in the code for each comment.

end WRITE A LOOPY PROGRAM - COMMENTS Is number > 0 start Ask user for a number Convert to integer Display number Subtract one Yes No

WRITE A LOOPY PROGRAM - CODE Extension: Get you program to calculate the factorial of the number. Hint: factorial of 4 is 4 * 3 * 2 * 1.

 With your classmate you have 2 mins to discuss…  What was most difficult in the program  What was most fun  What was the boring part CLASS DISCUSSION

WHILE STATEMENT BREAK while expression : statement 1 statement 2 break This command quits from the while statement – even if the expression is still true. Statements are executed while the expression is true Notice the indentation – this defines which statements are in the while statement

GUESS THE NUMBER – VERSION 2  Remember this – guessing a random number….

 I want you to make it even better  Give the user 6 chances to guess the number - use while statement  Let them know if their guess is too high - if statement  Let them know if their guess is too low - if statement GUESS THE NUMBER – VERSION 2

WHAT DO WE NEED TO CHANGE

Set guesses to zero Exit from while loop Add 1 to guessesUser has a guess No Guess = number Yes No Guess > number Tell user too high Yes Tell user too low Guess < number Yes Guesses > 6 No Yes Exit from while loop You have previously written most of this program. All you need to do is write the new section

Set guesses to zero Exit from while loop Add 1 to guesses User has a guess No Guess = numbe r Yes No Guess > numbe r Tell user too high Yes Tell user too low Guess < numbe r Yes Guess es > 6 No Yes Exit from while loop

WRITE THE CODE

EXTENSIONS  Make the random number range from 1 to 30  Let them know the random number if they fail to guess it.

PLENARY  Complete the Lesson 5 plenary Quiz