As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Log in:  Launch/Start Alice  Any questions?

Slides:



Advertisements
Similar presentations
(Say each word as it appears on the screen.)
Advertisements

(Say each word as it appears on the screen.)
As you come in… Sign in (in back) and pick up Badge Name Card – on computer… Log in: Launch/Start Alice Any questions? (of any kind) DOWNLOADS FOR TODAY:
As you come in… DOWNLOADS FOR TODAY: Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)?
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010 modified July 2011.
Chapter 7.2 While – Conditional Loops. What is the BEST description of how many times a while loop executes? A.Some fixed number of times that the programmer.
Lecture 12 or President’s Day Holiday Chapter 7.2 While Loops – Finish up our race of the penguins.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Any questions? (of any kind)  Put on index.
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU.
Coloring Randomly: Random Selection in Alice By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008.
How Tall Are You? Introducing Functions By Jenna Hayes under the direction of Professor Susan Rodger Duke University July 2008 Updates made June 2014 by.
As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Any questions? (of any kind)  Put on index.
Repetition Structures
While: Indefinite Loops Alice. Repetition In some situations, we don’t know exactly how many times a block of instructions should be repeated. All we.
While: Indefinite Loops Sec 8-14 Web Design. Objectives The student will: Understand what an Indefinite Loop is Understand how create an indefinite loop.
High-Frequency Words Second Grade Room B10.
Repetition: Definite Loops Alice. Repetition In many kinds of animations, especially simulations and games, some actions happen again and again. Example:
Lecture 8 Lab 4: It’s up! (Thursdays we post next week’s) – Plan out what you want, bring an implementation strategy diagram – Key Lab: If you’ve been.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
CS320n –Visual Programming LabVIEW Control Structures.
Creating a 3D Interactive Story Prof. Susan Rodger Duke University Feb. 24, 2007.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
As you come in…  DOWNLOADS FOR TODAY:  CarGameTeacherStarter.a2w  Online student textbook.
The.
Lecture 11 Alice Project Deliverable 1: Extension to Midnight! Midterm next class – Midterm review 4-6pm WED Pepper Canyon Hall 106 – Red scantron (1/2.
220 Dolch Words.
This will let you see the game you are going to play on the inside. It will help you see what all goes into creating instance to that goes into setting.
Study Guide For Test Chapter 5, 6,& 7 Test is Friday, May 15th.
Events Chapter 7 Part 2. While a Key is Pressed Event Specialized event An event occurs when you press a key and continues until you take your finger.
CompSci 4 Chap 7 Sec 2 Apr 7, 2005 Prof. Susan Rodger Note: thanks to Wanda Dann and Steve Cooper for slide ideas.
Changing Color, Using Text Objects, and Random Selection in Alice By Jenna Hayes Under the direction of Professor Susan Rodger Duke University, July 2008.
Programming: Simple Control Structures Alice. Control Statements We have been using Do in order and Do together to control the way instructions are executed.
Four Fundamental Pieces Instruction Control Structure Function Expression.
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.
By Melissa Dalis Professor Susan Rodger Duke University June 2011 Multiplication Table.
© Jalal Kawash Programming Peeking into Computer Science 1.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
1 ball, 2 ball, red ball, blue ball By Melissa Dalis Professor Susan Rodger Duke University June 2011.
Mathematical Expressions, Conditional Statements, Control Structures
BLT # go help look at run.
The. to and a I you it in said for up look.
Dolch list for Ms. Hrouda’s Class!. List 1 the was.
Sight Word List.
Algorithms Writing instructions in the order they should execute.
Chapter 6.2 Execution Control with If/Else and Boolean Functions.
Bunny Eat Broccoli Repetition – Simple loops and Conditional loops Susan Rodger Duke University July 2011.
Repetition Structures Chapter 5 Part The While Instruction  Combines Loop and the condition that is also used in If/else statements  The loop.
Dolch 220 Sharks! a is it am to an red up.
Obj: Programming: Simple Control Structures HW: Read section 3 – 2 AC3 D2 Do Now: 1.Log on to Alice. Open the file firstEncounter.a2w located in the folder.
5 Event Handling Interactive Programming Suggested Reading Interaction: Events and Event Handling, Supplemental Text for CPSC 203 Distributed this term.
CompSci 4 Chap 6 Sec 2 Sep 30, 2010 Prof. Susan Rodger “All your troubles are due to those ‘ifs’,” declared the Wizard. If you were not a Flutterbudget.
Repetition everywhere – comparing while in a method and as an event Susan Rodger Duke University July 2010.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 4-1 Lecture Objectives To understand: –what values can be stored in a Boolean.
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
Repetition Structures The long awaited …. Repetition Structures I repeat …
CS320n –Visual Programming Execution Control with If / Else and Boolean Functions (Slides 6-2-1) Thanks to Wanda Dann, Steve Cooper, and Susan Rodger for.
Conditionals.
A. Kindergarten Dolch List 2013 Sight Words am are.
A. and away big blue can come down find for.
Simple Control Structures
Control Structures
Repetition Control Structures
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Repetition Structures
Programming: Simple Control Structures
Decision Statements.
Presentation transcript:

As you come in…  Sign in (in back) and pick up  Badge  Name Card – write your first name LARGELY on back  Log in:  Launch/Start Alice  Any questions? (of any kind)

Flow of Control: How Computer Programs are “Executed”  Sequential execution (Do In Order)  Parallel execution (Do Together)  Conditional execution (if/else statement)  Powerful for creating programs that don’t ALWAYS do the same thing  Repeated execution (Counted Loop)  Powerful for having the computer repeat our instructions multiple times  TODAY: While loop: Repetition not defined by a specific number (a count) Controlled by Boolean expression (true or false, keep looping?)

Flow of Control: How Computer Programs are “Executed”  Sequential / Parallel execution  Conditional execution (if/else statement)  Repeated execution (Counted Loop, While loop)

Wrap Up: Nested If Statements

Ball Guess Game

Practice: “In Class Clicker Discussion Questions” 1) Individual Thinking, Vote 2) Group Discussion (with 1-2 other students) 3) Group Vote 4) Class-Wide Discussion: a) call on groups to share thinking b) explain yourself (see comments in PPT) OR show video of my explanation Pre-Class preparation: Work Through Online Module Answer Embedded Questions Reflecting Questions (as quiz?)

What does this code do?  Assume that you have an event so that when you click on an igloo it calls a my first method and sends the igloo as a parameter  Next we’ll show you my first method and ask you what it does

What does this code do? When blue, red or green… Feedback Paraphrase Justify World.my first method

How many of the following are true? 1. When the igloo is blue, says Ice Cold! 2. When the igloo is red, says Hot! 3. When the igloo is blue, says Ice Cold! AND then says Try again! 4. When the igloo is green, nothing happens

Feedback Paraphrase Justify 1.blue, says Ice Cold! 2.red, says Hot! 3.blue, says Ice Cold! AND then says Try again! 4.green, nothing happens A)1B) 2C)3D) 4E)

BTW: Online Book: Nested Ifs  Interactive, Car drive toward clicked on magnet  But only if thing clicked on IS magnet ( )  Space Ship Take Off  But only if all balls are blue ( )

Flow of Control: How Computer Programs are “Executed”  Repeated execution (Counted Loop)  Powerful for having the computer repeat our instructions multiple times  TODAY: While loop: Repetition not defined by a specific number (a count) Controlled by Boolean expression (true or false, keep looping?)

Online Textbook: 10.5: Zombie Chases Lunchlady  Let’s go play the video…  Question: When should we “keep chasing”?  Until the zombie catches the lunchLady OR (said differently)  We should first add the condition that, while it is true, the statements to make the zombie and lunchlady move will repeatedly execute. This condition is: zombie is at least 1 meter from lunchLady. Let’s code it: Download from Meeting 4: Module10.5TeacherStarter.a2w

Solution  Keep chasing/looping WHILE zombie is more than 1 meter from the lunchLady

Solution  Keep chasing/looping WHILE zombie is more than 1 meter from the lunchLady Except, yes, this is silly since he always catches her in 3 “steps”

Online Textbook 10.5 fixes this…  Random turn (0-1 revolution)  Random distance for lunchLady and zombie

Visualize in head… LunchLady zombie 1 meter

What “states” can we have? LunchLady zombie LunchLady zombie

What “states” can we have? LunchLady zombie LunchLady zombie 1) Should we keep looping? YES 2) Should we keep looping? NO 3) Write boolean expression that evaluates To TRUE for situation 1 and FALSE for situation 2

Hint to getting while loops right  Humans naturally think “until”  I’ll keep spending until I run out of money (balance <= 0)  I’ll keep dancing until I fall asleep  Computers use “while” loops – the opposite  I’ll keep spending while I still have money (balance > 0)  I’ll keep dancing while I am not asleep  While I have a dirty dish, I’ll keep washing dishes

Let’s have a race…  A  Wind up penguin (he just goes) While loop with “walk and spin” inside it  Jet-pack penguin2 (controlled by <- event) Moves forward.5 meters  Race to a stop sign (within 2 meters)  Whenever someone gets within 2 meters  Stop looping (going)

While loops in Alice tend to be used when…  You have a user controlled (hence, not predictable) event  So you don’t know when the user might Click on an object Type a key, User types a number (pick a number between 1-10, etc.  You have (not predictable) actions controlled by, for example, random numbers  E.g. the lunchlady/zombie or fish/shark case

When should we keep going? e.g. while loop expression true (P1: wind up, P2: jet pack) CasesABCD P1, P2 outsideTTTT P1 inside, P2 outsideTTTF P2 inside, P1 outsideTTFF P1, P2 insideTFFF

Which while loop header (tile) would you use to control the “going”?

Let’s Build the Code!  Download from  Meeting 4: JetPackPenguinTeacherStart.a2w  Plan:  Explore object positions  Create event that moves jet pack penguin 0.5 meters whenever is pushed. (Test)  SIMPLIFY: Create loop that makes windup penguin move repeatedly (forever), 0.35 meters (at same time as “walks” and windupKey “rolls” 0.25 revolutions)  CORRECT: change loop to have the game end (e.g. windup penguin stops walking) when either penguin “wins” (gets within 2 meters of stop sign) WHILE:_________________________________________

This would STOP the game (evaluate to false) when A. Both penguins must be close to the stop sign B. Either penguin is close to the stop sign C. Neither penguin is close to the stop sign D. I don’t know What does the other one do?

CasesE1E2Evaluates To (keep playing while true) P1, P2 outsideTT P1 inside, P2 outside FT P2 inside, P1 outside TF P1, P2 insideFF Truth Table for OR logical operator

CasesE1E2Evaluates To (keep playing while true) P1, P2 outsideTT P1 inside, P2 outside FT P2 inside, P1 outside TF P1, P2 insideFF Truth Table for AND logical operator

Useful tool: “Life points”  Use: to keep track of “points” in a game  2 “cylinder” objects set on top of each other  Grey is “background”  Yellow is in “front”  Yellow moves down a bit each time “you lose a point”  The game is over when the yellow cylinder is  Distance to the ground >= cylinder height.  (So while not, game is ongoing…)

Coming Up…  Week 5: Compound Boolean Expressions and if statements and while loops  Week 6: Functions, Mathematical expressions, parameters, methods  Week 7: Functions, parameters, methods and events  Week 8: Lists