Download presentation
Presentation is loading. Please wait.
Published byRobert Blake Modified over 8 years ago
1
Computer Science 1000 LOGO II
2
Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than (>) unlike Excel and Scratch, the input to must be numbers = can be used to compare strings
4
Boolean Expressions - Uses Boolean expressions are rarely used on their own instead, they are used as input to other expressions a common example: conditional statements a programming construct that allows execution of a particular set of statements only under certain conditions
5
If Statement the simplest conditional two parts a Boolean expression a set of statements in brackets syntax: if booleanEx [ statements ] These execute if this is true
8
If Statements and Procedures by placing an if statement in a procedure, we can conditionally execute code based on user input example: write a function called forwardOnly, that takes a single number as input, and moves the turtle forward by that amount, but only if that amount is positive. Otherwise, the turtle should not move.
12
IfElse an if statement allows us to specify what happens when an expression is true an ifelse statement allows us to also specify what happens when the statement is false syntax: ifelse booleanEx [true statements] [false statements] These execute if this is true, otherwise these execute
16
Example: rewrite our function called forwardOnly, that takes a single number, and moves the turtle forward by that amount, but only if that amount is positive. Otherwise, the program should print Error
21
Multiple Inputs procedures allow multiple inputs from users when creating the procedure give each input a unique variable name when calling the procedure specify one value for each input note that they are applied in order
24
Example: rewrite the dashedLine example so that it takes two parameters. The first parameter determines how many dashes are drawn. The second parameter determines how long the dashes are.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.