Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than.

Similar presentations


Presentation on theme: "Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than."— Presentation transcript:

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

3

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

6

7

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.

9

10

11

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

13

14

15

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

17

18

19

20

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

22

23

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.

25

26

27


Download ppt "Computer Science 1000 LOGO II. Boolean Expressions like Excel and Scratch, LOGO supports three Boolean operators less than (<) equal (=) greater than."

Similar presentations


Ads by Google