 Type Called bool  Bool has only two possible values: True and False.

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

Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
Conditional Statements Introduction to Computing Science and Programming I.
Overview Program flow Decision / branching / selection structures True & False in Python Comparison operators & Boolean expressions if … if … else if …
1 9/15/06CS150 Introduction to Computer Science 1 Combined Assignments, Relational Operators, and the If Statement.
1 9/24/07CS150 Introduction to Computer Science 1 Relational Operators and the If Statement.
Conditions What if?. Flow of Control The order of statement execution is called the flow of control Unless specified otherwise, the order of statement.
COMP 14 Introduction to Programming Miguel A. Otaduy May 18, 2004.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 4- 1.
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
1 CS150 Introduction to Computer Science 1 Relational Operators and the If Statement 9/22/08.
Logical Operators and Conditional statements
Chapter 4 Making Decisions
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 30, 2005.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Introduction to Programming (in C++) Data types and visibility Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. Computer Science, UPC.
The Data Element. 2 Data type: A description of the set of values and the basic set of operations that can be applied to values of the type. Strong typing:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
Decision Structures and Boolean Logic
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
2440: 211 Interactive Web Programming Expressions & Operators.
Computer Science Selection Structures.
CSCI 1100/1202 January 28, The switch Statement The switch statement provides another means to decide which statement to execute next The switch.
1 Data Comparisons and Switch Data Comparisons Switch Reading for this class: L&L 5.3,
Copyright © 2012 Pearson Education, Inc. Chapter 4: Making Decisions.
INLS 560 – C ONDITIONALS Instructor: Jason Carter.
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.
Making Decisions. 4.1 Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 4: Making Decisions.
Liang, Introduction to C++ Programming, (c) 2007 Pearson Education, Inc. All rights reserved X1 Chapter 3 Control Statements.
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 4: Making Decisions.
Chapter Making Decisions 4. Relational Operators 4.1.
Flow of Control Unless indicated otherwise, the order of statement execution through a method is linear: one after the other in the order they are written.
ICT Introduction to Programming Chapter 4 – Control Structures I.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 4 Making Decisions.
Decision Structures, String Comparison, Nested Structures
Chapter 3 Boolean Expressions Section 3.2 Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
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.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Lecture 6 – Selection FTMK, UTeM – Sem /2014.
Operators A binary operator combines two values to get one result: x OP y where OP is any binary operators such as +, -, *, /, ==, !=, >, &&, or even =.
ICS102 Lecture 8 : Boolean Expressions King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Control Flow (Python) Dr. José M. Reyes Álamo. 2 Control Flow Sequential statements Decision statements Repetition statements (loops)
Today… Operators, Cont. Operator Precedence Conditional Statement Syntax. Winter 2016CISC101 - Prof. McLeod1.
Rational Expressions relational operators logical operators order of precedence.
if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false.
APS105 Deciding 1. Comparing 2 Relational Expressions Relational expression: –Compare two values (or values of variables) Examples: x > 5 income < expenses.
Control Flow (Python) Dr. José M. Reyes Álamo.
Chapter 4: Making Decisions.
CMPT 201 if-else statement
Data Types, Identifiers, and Expressions
Expressions An expression is a portion of a C++ statement that performs an evaluation of some kind Generally requires that a computation or data manipulation.
Topics The if Statement The if-else Statement Comparing Strings
Chapter 4: Making Decisions.
Topics The if Statement The if-else Statement Comparing Strings
Relational Operators Operator Meaning < Less than > Greater than
Logical Operations In Matlab.
Comparing Strings Strings can be compared using the == and != operators String comparisons are case sensitive Strings can be compared using >, =, and.
Expressions.
The Data Element.
Relational Operators.
Winter 2019 CISC101 4/16/2019 CISC101 Reminders
Life is Full of Alternatives
The Selection Structure
The Data Element.
Using C++ Arithmetic Operators and Control Structures
Boolean Expressions September 1, 2019 ICS102: The course.
3.0 - Design A software design specifies how a program will accomplish its requirements A design includes one or more algorithms to accomplish its goal.
Conditionals.
Presentation transcript:

 Type Called bool  Bool has only two possible values: True and False

 Three Basic operators: and, or, not  Not > and > or  Not is a unary operator, applied to one value  negation of an expression  And and or are binary operators -  How do they work let us see in the shell??

 Doing comparisons using the following binary relational operators: SymbolOperation >Greater than <Less than >=Greater than or equal to <=Less than or equal to ==Equal to !=Not equal to DO NOT CONFUSE = for assignment with == for equality!

 Arithmetic operators have a higher precedence than relational operators.  + and / are evaluated before  Relational operators have higher precedence than Boolean operators  Comparisons evaluated before and, or, not  Chain Rules when they seem natural in mathematics!!

 Characters in strings are represented by integers, this encoding is called ASCII (American Standard Code for Information Interchange)  Example: A = 65, space = 32, lowercase z = 122  Used to compare strings in alphabetical order  If character from one string is greater than character from other  first string is grater than second as in z > A because (z = 122) > (A = 65)  Lexicographical comparisons: check whether one string inside another one

If >: > Condition  Expression Block  Statements indented to be executed if condition is true To add more cases, use elif (else if) or else If >: > Elif >: > Else: >