Download presentation
Presentation is loading. Please wait.
Published byStewart Shields Modified over 9 years ago
1
Conditionals Conditional statements, called conditionals for short, are statements in the if-then or if-then-else form. Examples: “If the alarm goes off, I hit the snooze button” “If I don’t have coffee, then Watch Out!” “If the Red Sox win, then I am happy else I am sad”
2
Conditionals in BYOB Conditionals evaluate the conditional expression to determine if it is TRUE or FALSE
3
Conditional Expressions in BYOB Are either TRUE or FALSE at that instant Pointed at both ends 3
4
Conditional Examples
6
Booleans & Compound Conditionals More than one conditional expression “If the Red Sox win or the Yankees lose, I am happy” “If the Red Sox win and the Yankees lose, I am very, very happy!” The following are Boolean expressions: ‘And’ – Both Expressions are true ‘Or’ – At least one expression is true ‘Not’ – If it’s true, then it becomes false; if it’s false, then it becomes true
7
Compound Conditional Example
8
Conditional controls Other controls use conditions, too
9
Classwork Count up from 1 to 10 Use OR Use a variable keep track of where you are Output the numbers using: Now count down from 10 to 1 Use the conditional loop you didn’t use above Now count up from 1 to 10, outputting only even numbers (using any method)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.