Complex Conditionals Human languages are ambiguous

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

GAME:IT Junior Learning Game Maker: The Control Tab.
The If Then Else Statement Using JavaScript TIP The If Statement is the fundamental control structure that allows branches in the flow of control in a.
Selection Victor Norman CS104 Calvin College. Reading Quiz Counts toward your grade.
CS001 Introduction to Programming Day 3 Sujana Jyothi
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
ICM Week 2. Structure - statements and blocks of code Any single statement ends with semicolon ; When we want to bunch a few statements together we use.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
VARIABLES, TYPES, INPUT/OUTPUT, ASSIGNMENT OPERATION Shieu-Hong Lin MATH/CS Department Chapel.
Transparency 2 Click the mouse button or press the Space Bar to display the answers.
In.  This presentation will only make sense if you view it in presentation mode (hit F5). If you don’t do that there will be multiple slides that are.
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.
Continuous February 16, Test Review What expression represents the zip car eligibility rules of at least 18 years old and no incidents?
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
Agenda Exam #1 Review Modulus Conditionals Boolean Algebra Reading: Chapter Homework #5.
Visual Basic CODE. Basics of Code Declaration Declaration Set aside a named place to put things Set aside a named place to put things Assignment Assignment.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Introduction to Programming G50PRO University of Nottingham Unit 2 : Introduction To Scratch Paul Tennent
Algorithms Writing instructions in the order they should execute.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Learning Javascript From Mr Saem
Intro CS – Logic & Operators Lesson Plan 5. Goals  Students can explain basic logical operators  AND, OR, NOT  Students can create truth tables for.
IF STATEMENTS AND BOOLEAN EXPRESSIONS. BOOLEAN EXPRESSIONS Evaluate to a value of true or false Use relational or equivalence operators Boolean operators.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Repetition Statements
Scratch Programming Cards
Click the mouse button or press the Space Bar to display the answers.
C++ LANGUAGE MULTIPLE CHOICE QUESTION
Click the mouse button or press the Space Bar to display the answers.
Complex Conditionals Human languages are ambiguous
Section 7.1 Logical Operators
Debugging and Random Numbers
IF statements.
White-Box Testing.
Expressions and Control Flow in JavaScript
Lesson 9: "if-else-if" and Conditional Logic
Ruth Anderson UW CSE 160 Winter 2017
Iteration with While You can say that again.
Java I.
Conditional Statements
More Selections BIS1523 – Lecture 9.
Lesson 8: Boolean Expressions and "if" Statements
BBC Microbit.
Conditions and Ifs BIS1523 – Lecture 8.
Computers & Programming Languages
HAPPY NEW YEAR! Lesson 7: If-statements unplugged
Ruth Anderson UW CSE 140 Winter 2014
Three Special Structures – Case, Do While, and Do Until
Algorithm and Ambiguity
Computer Science Core Concepts
Find the reference angle for the angle measuring {image}
Python Programming Language
ICT Gaming Lesson 3.
“Under the hood”: Angry Birds Maze
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Variables & getting info from the user
CS 240 – Lecture 7 Boolean Operations, Increment and Decrement Operators, Constant Types, enum Types, Precedence.
The Data Element.
Relational Operators.
Using Decision Structures
Instructor: Craig Duckett
Simple Branches and Loops
Introduction to Programming
The Data Element.
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Did a few weeks ago. tag would work..
Presentation transcript:

Complex Conditionals Human languages are ambiguous Computer languages must be precise Complex Conditionals Complete this conditional statement: IF it snows and the temperature is below 32 _________________ ELSE _________________ CSD Code Studio Level 9

Review Boolean: true or false Expression: something you evaluate to get an answer like 1+5 or x < 7 Conditional or Boolean expression: an expression with a Boolean result Conditional statement: chooses what to do based on a conditional expression

These are conditional statements Complex conditional

Write your own conditional statements in code form using Boolean expressions: If the bell rings you should log out. You can buy french fries if you have at least 50 cents. If the bird sprite is on the top half of the screen, rotate it by 10. Point out ambiguities in English that make it difficult to know exactly what the code should do Point out that variables would need to be declared and assigned in order to use these conditionals.

Conditional statements in code form using Boolean expressions: If the bell rings you should log out. You can buy french fries if you have at least 50 cents. If the bird sprite is on the top half of the screen, rotate it by 10. Ask: is each condition a Boolean expression? How do you decide on variable names?

These are more Boolean functions in CodeLab mouseDidMove() Returns true if the mouse did move if(mouseDidMove()) {} mouseWentDown(side) Returns true once when the specified mouse button is pressed down if(mouseWentDown("left")) {} mouseWentUp(side) Returns true once when the specified mouse button is released if(mouseWentUp("left")) {} keyWentDown(key) Returns true once when the specified key is pressed down if(keyWentDown("e")) {} keyWentUp(key) Returns true once when the specified key is released if(keyWentDown("m")) {}

Video (4:18)

What happens? When do the gear rotate? When the space key is pressed down (Stage 9 puzzle 3) What happens if the space key is not pressed down? Nothing, the gears stay still unless there is other code we cannot see.

What happens? What’s the difference between this code and the last one? The gears always move but they change direction if the space key is pressed down.

Work in code studio Stage 9 Human languages are ambiguous Computer languages must be precise