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.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
If Statements & Relational Operators Programming.
This presentation includes custom animations. To view the animations, you must view the presentation in Slide Show mode and activeX controls must be allowed.
Mrs. Chapman. Tabs (Block Categories) Commands Available to use Script Area where you type your code Sprite Stage All sprites in this project.
Slide 1 Summary Two basic concepts: variables and assignments Some C++ practical issues: division rule, operator precedence  Sequential structure of a.
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
1 CS 105 Lecture 4 Selection Statements Wed, Jan 26, 2011, 6:05 pm.
If Statements. COMP104 If / Slide 2 Three Program Structures * Sequence - executable statements which the computer processes in the given order * Choice.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Conditional Statements Control Structures.
1 Lecture 7:Control Structures I (Selection) Introduction to Computer Science Spring 2006.
BOOLEAN LOGIC CSC 171 FALL 2004 LECTURE 7. ASSIGNMENT Review Quiz # 2 Start reading Chapter 5.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
Mr. Wortzman. Tabs (Block Categories) Available Blocks Script Area Sprite Stage All sprites in this project.
Fundamentals of Python: From First Programs Through Data Structures
Computer Science 101 Boolean Algebra. What’s next? A new type of algebra – Helps us A new type of algebra – Helps us With logical reasoningWith logical.
Conjunctions, Disjunctions, and Negations Symbolic Logic 2/12/2001.
True or False Unit 3 Lesson 7 Building Blocks of Decision Making With Additions & Modifications by Mr. Dave Clausen True or False.
Fundamentals of Python: First Programs
COMP 1001: Introduction to Computers for Arts and Social Sciences Programming in Scratch Monday, May 16, 2011.
Using Control Structures. Goals Understand the three basic forms of control structures Understand how to create and manage conditionals Understand how.
CSci 125 Lecture 10 Martin van Bommel. Simple Statements Expression followed by semicolon Assignments total = n1 + n2; Function calls printf(”Hello.\n”);
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
1 Introduction to Abstract Mathematics The Logic and Language of Proofs Instructor: Hayk Melikya Proposition: Informal introduction to.
Order of Operations Topic
An Introduction to Programming Using Alice Boolean Logic.
Conditionals & boolean operators
Computer Science 210 Computer Organization Introduction to Boolean Algebra.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 4 Decision.
Programming Structure
CONTROL FLOW The order in which blocks are executed is called the “control flow” of the script So far all our scripts have just executed blocks in the.
6.1 Logic Logic is not only the foundation of mathematics, but also is important in numerous fields including law, medicine, and science. Although the.
Assignment statement: Assigns a value to a variable Variable must appear on the left side, value on the right side of the assignment operator Right side.
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/
1 CS 177 Week 5 Recitation Booleans and Control Flow.
Computer Programming Boolean Logic Trade & Industrial Education
Higher Computing Software Development -So Far- 5/10/10.
Using Control Structures. Goals Understand the three basic forms of control structures Understand how to create and manage conditionals Understand how.
Operators.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
ARITHMETIC OPERATORS COMPARISON/RELATIO NAL OPERATORS LOGIC OPERATORS ()Parenthesis>Greater than &&And ^Exponentiation=>=
CS 104 – Fall 2011 Exploring Computer Science Build Your Own Blocks September 19, 2011.
AP Computer Science A – Healdsburg High School 1 Unit 7 - Conditional statements - Logical operators in Java - Example.
Propositional and predicate logic
Computer Programming Boolean Logic.
CMSC201 Computer Science I for Majors Lecture 03 – Operators
Computer Science 210 Computer Organization
Chapter 3: Decisions and Loops
Sequence, Selection, Iteration The IF Statement
Assignment statement:
Expressions and Control Flow in JavaScript
Boolean logic Taken from notes by Dr. Neil Moore
Topics The if Statement The if-else Statement Comparing Strings
Selection CIS 40 – Introduction to Programming in Python
Computers & Programming Languages
Chapter 1 The Foundations: Logic and Proof, Sets, and Functions
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Computer Science 210 Computer Organization
Chapter (3) - Looping Questions.
Summary Two basic concepts: variables and assignments Basic types:
Introduction to Decision Structures and Boolean Variables
Computer Science Core Concepts
Chapter 3: Selection Structures: Making Decisions
Using Decision Structures
Chapter 3: Selection Structures: Making Decisions
Repetition Statements (Loops) - 2
Computer Programming Boolean Logic Trade & Industrial Education
Conditionals.
Presentation transcript:

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 #2  Review of control constructs  Examples in BYOB Scratch Wednesday  Quiz #2 on Wednesday  Review Research Paper #1  More BYOB Scratch ideas

Review: Decision Structure “if” statements are used to test whether a certain condition is met This requires comparison operators and a way to connect multiple comparisons to create complex statements

Comparison Operators Relational Operators: Evaluate to true or false SymbolMeaning <Less than <=Less than or equal to =Equal to >Greater than >=Greater than or equal to <>Not equal to Scratch does not provide <>, >= or <= –These can be simulated as x > 10 or x = 10, and not x = 10

Operator Precedence What is * 4? What about (2 + 3) * 4? The concept of operator precedence dictates which operators are applied first and have higher importance In most programming languages, the order is: 1. terms inside parentheses or brackets 2. exponents and roots 3. multiplication and division As they appear left to right 4. addition and subtraction As they appear left to right

Comparison Operators: You Answer

Boolean Operators Boolean logic – basis of computer logic, used to create complex comparisons Invented by George Boole, an English mathematician and philosopher... no general method for the solution of questions in the theory of probabilities can be established which does not explicitly recognise... those universal laws of thought which are the basis of all reasoning...

Boolean Operators AND  Both conditions must be true in order for the entire condition to be true OR  At least one condition must be true in order for the entire condition to be true NOT  Opposite; if the condition is true, the result is false, and if the condition is false, the result is true Operator Precedence  Not  And  Or

Boolean Operators: AND You Answer

Boolean Operators: OR You Answer

Boolean Operators: Complex You Answer

Truth Tables PQP or Q TT TF FT FF PQP and Q TT TF FT FF PNot P T F

Implication, we denote as => "If it rains, I will stay at home" There are 4 possibilities: 1) it rains and he stays at home This is compatible with the statement: he did not lie. 2) it rains and he does not stay at home This is NOT compatible with the statement: he lied. 3) it does not rain and he stays at home This is compatible with the statement: he did not lie. 4) it does not rain and he does not stay at home This is compatible with the statement: he did not lie. Truth Tables PQP => Q TT TF FT FF

Grader Write a program to assign a letter grade to a given numeric grade.  If the given grade is between 90 and 100, print an A.  If the given grade is between 80 and 89, print a B.  If the given grade is between 70 and 79, print a C.  If the given grade is less than 70, print an F.

Review: Loops Loops are used to perform a single task repetitively until a specified condition is met

Types of Loops Infinite loops  The command(s) placed inside a never ending loop will repeat until the program is stopped For loops  The loop will execute for a specified number of times

Types of Loops While loop  This loop will repeat while the specified condition is true Do Until loop  This loop will repeat until the specified condition is true

Class Grader Write a program to average three grades per student. The grades will be submitted by the user, and the number of students in the class should be a random number.  If the average grade is between 90 and 100, print an A.  If the average grade is between 80 and 89, print a B.  If the average grade is between 70 and 79, print a C.  If the average grade is less than 70, print an F.

Next Time Quiz #2 9/14/11 HW #2 due 9/21/11 Feel free to both Dr. Gray and Amber with any questions