An Introduction to Programming Using Alice Boolean Logic.

Slides:



Advertisements
Similar presentations
Chapter 4: Control Structures I (Selection)
Advertisements

C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
COMP 14 Introduction to Programming Mr. Joshua Stough February 7, 2005 Monday/Wednesday 11:00-12:15 Peabody Hall 218.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
Insight Through Computing 3. Introduction to Conditionals Boolean expressions The If-Else Construct And, or, not.
Fall 2007ACS-1805 Ron McFadyen1 Boolean functions & expressions A boolean function is one that returns true or false The guidelines for class-level methods.
Chapter 2: Java Fundamentals Operators. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR Page 2 Content Group of Operators Arithmetic Operators Assignment.
Introduction Chapter 4: Control structures. Introduction to OOPDr. S. GANNOUNI & Dr. A. TOUIRPage 2 Objectives What are control structures Relational.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
Thursday, December 14, 2006 “Would you tell me, please, which way I ought to go from here?” “That depends a good deal on where you want to get to,” said.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 30, 2005.
22C:19 Discrete Math Boolean Algebra & Digital Logic Fall 2010 Sukumar Ghosh.
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
BUILDING COMPUTER CIRCUITS prepared by Burak Galip ASLAN September, 2006 BOOLEAN LOGIC AND GATES CONTROL CIRCUITS.
CIS 103 — Applied Computer Technology Last Edited: September 17, 2010 by C.Herbert Single Table Queries in SQL SELECT first, last, phone FROM student WHERE.
Exercises A-Declare a variable of double type with initial value=0.0; B- Declare a constant of String type with initial value=“Good” C- Declare a variable.
Chapter 2 part #4 Operator
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
CHAPTER 2 PART #4 OPERATOR 2 nd semester King Saud University College of Applied studies and Community Service Csc 1101 By: Asma Alosaimi Edited.
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
1 © 2000 John Urrutia. All rights reserved. Qbasic Looping Statements & Formatted Output.
Problem Solving with Decisions
Conditionals & boolean operators
5-1 Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional statements,
Selection Boolean What is Boolean ? Boolean is a set with only two values : –true –false true and false are standard identifiers in Pascal, called Boolean.
CSC 270 – Survey of Programming Languages C Lecture 5 – Bitwise Operations and Operations Miscellany.
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
Chapter 7 Selection Dept of Computer Engineering Khon Kaen University.
Programming 1 DCT 1033 Control Structures I (Selection) if selection statement If..else double selection statement Switch multiple selection statement.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CUSACK CHAPT 4.
Chapter 4 Control Structures: Selection We introduced the three fundamental control structures from which all programs are developed: 1. Sequence structures.
Decision Structures and Boolean Variables. Sequence Structures Thus far, we’ve been programming “sequence structures” Thus far, we’ve been programming.
Quiz 3 is due Friday September 18 th Lab 6 is going to be lab practical hursSept_10/exampleLabFinal/
ICT Introduction to Programming Chapter 4 – Control Structures I.
Logic and Boolean Algebra. Logic statements  Real life statements  “I use public transportation when the car is broken and I have to go to work”  “All.
Boolean Logic in Programming. Boolean Logic Branching and looping routines both contain conditions that are either true or false. In 1854 George Boole.
CEC 220 Digital Circuit Design Boolean Algebra I Wed, Sept 2 CEC 220 Digital Circuit Design Slide 1 of 13.
CONDITIONALS. Boolean values Boolean value is either true or false It is name after the British mathemetician, George Boole who first formulated Boolean.
13 October 2015Birkbeck College, U. London1 Introduction to Computer Systems Lecturer: Steve Maybank Department of Computer Science and Information Systems.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Logical Thinking CS 104 9/12/11. Agenda Today  College Board survey reminder  Note: Simple “how to” guide on Scratch posted on eLearning  Review HW.
BOOLEAN OPERATIONS AND CONDITIONALS CHAPTER 20 1.
CSE202: Lecture 5The Ohio State University1 Selection Structures.
Types, Truth, and Expressions Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Types, Truth, and Expressions Intro to Computer Science CS1510, Section 2 Dr. Sarah Diesburg.
Random Functions Selection Structure Comparison Operators Logical Operator
Introduction to Decision Structures and Boolean Variables
CPS120 Introduction to Computer Science
Single Table Queries in SQL
Boolean Algebra.
4-1 LOGIC OPERATIONS In Chapter 3 we discussed the fact that data inside a computer is stored as patterns of bits. Logic operations refer to those operations.
JavaScript conditional
2-1 Making Decisions Sample assignment statements
Introduction to Decision Structures and Boolean Variables
Introduction To Robot Decision Making
Computer Science Core Concepts
ECS15 boolean.
Truth tables Mrs. Palmer.
Using C++ Arithmetic Operators and Control Structures
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Conditionals.
Types, Truth, and Expressions
Presentation transcript:

An Introduction to Programming Using Alice Boolean Logic

An Introduction to Programming Using Alice George Boole In1854, George Boole published “An investigation into the Laws of Thought, on which are founded the Mathematical Theories of Logic and Probabilities.” Boole outlined a system of logic and a corresponding algebraic language dealing with true and false values. 100 th Anniversary Edition

An Introduction to Programming Using Alice Boolean Logic Boolean logic is a form of mathematics in which the only values used are true and false. Boolean logic is the basis of all modern computing. There are three basic operations in Boolean logic – AND, OR, and NOT. 100 th Anniversary Edition

An Introduction to Programming Using Alice The AND Operation The AND operation is a binary operation, meaning that it needs two operands. c = a AND b Both a and b must be true for the result to be true. AND b TF a TTF FFF

An Introduction to Programming Using Alice The OR Operation The OR operation is also a binary operation with two operands. c = a OR b If either a OR b is true, then the result is true. OR b TF a TTT FTF

An Introduction to Programming Using Alice The NOT Operation The NOT operation is a unary operation with only one operand. c = NOT (a) It simply reverses the true or false value of the operand. NOT a TF FT

An Introduction to Programming Using Alice Logical Conditions Logical comparisons that are either true or false are most often used as the basis for the true and false values in Boolean logic. They are often used for simple conditions in branching and looping instructions. If (hours > 40) pay overtime If (age < 12) stay in the back seat While (count  10) print count increment count

An Introduction to Programming Using Alice Logical Comparison Operators ConditionIn MathIn Programming A equals BA = BA = B or A == B A is not equal to B A  B A<> B or A != B A is less than BA < B A is greater than BA > B A is less than or equal to B A  B A <= B A is greater than or equal to B A  B A >= B Six different comparison operators are used in mathematics and computer programming.

An Introduction to Programming Using Alice Compound Conditions Compound Boolean conditions can be created using the Boolean AND, OR and NOT operations in branching and looping instructions. If ( (hours > 40) AND (type = hourly) ) pay overtime If ( (age < 12) OR (height < 42 in.) ) stay in the back seat While ( (count <= 10) AND NOT (status = away) ) print name.count increment count

An Introduction to Programming with Alice Boolean Logic in Alice

Boolean Functions Functions in Alice that return true or false values are called Boolean functions. Alice has many such built-in functions, such as these two groups of basic Boolean logic functions and comparison functions.

They can be found on the world’s functions tab

They are used inside branching and looping instruction tiles

Boolean Functions The Boolean comparison functions can be used to create simple true or false conditions.

Boolean Functions The Boolean logic functions can be used to create compound conditions.

Boolean Functions Alice has many other world-level and object- level fuctions that return true or false values, such as the Boolean proximity functions shown here on aliceLiddel’s functions tab in the details area.

Boolean Functions They can be used anywhere that a Boolean value is needed, such as in this If/Else command.