SlideShare a Scribd company logo
1 of 11
 True or False?
 Boolean values are abstract concepts used in
computations.
 TRUE!
 Named in honor of George Boole who invented
a system of mathematics in which the abstract
concepts of true and false can be used in
computations
 Sometimes a program needs to ”decide” whether
or not to execute certain instructions
 All previous instructions have been consecutive
(sequence structure), that is:
 One
 After
 The
 Other
 in the order that they
appear.
 Now we can add some variability, interactivity,
and dynamisms into our applications.
 A conditional is what we refer to as a decision
structure. A decision is made is based upon a set of
rules. We mainly will be working with the if…then.
 An If decision executes a set of instructions if a
Boolean condition is true
 Instruction tests a condition
 The condition controls how the
application executes
 Ex.
 If an event occurs then a certain
outcome will happen.
 If it rains, then I will wear a rain coat.
 Conditional arguments are Boolean expressions.
 We use relational operators to form Boolean
statements.
 Operator Meaning
 == equal to
 < less than
 <= less than or equals to
 > greater than
 >= greater than or equal to
 != not equal to
 Common Mistake: Confusing = with ==
 Code:
Creating a decision structure:
if (expression):
statement
 To execute more than one statement in a block they must be indented
equally:
if (score > 90):
grade = 'A'
print(“Good Job!n”)
print(“Not part of the conditions execution”)
 Good Programming: Commenting conditional blocks
 Common Mistakes: Forgetting equal indent, forgetting :, forgetting
space after if
 Good Practices: Use a tab not a space (easier to line up and
troubleshoot)
Space
Indent
 Code:
 Creating a button object
 GPIO.setup(pin# , GPIO.IN)
 Using button functions to determine if
triggered
 if (GPIO.input(pin#) == False):
Command
Command
 We can nest conditional statements to have several decisions
structures evaluated within one decision tree.
 This allows an application to check multiple situations for a
single desired outcome.
 With an if statement if it evaluates to true it is true the body
statements executed
 However, with an else it will execute when the if statement is
false
 If and else compliment each other
 50/50
 Two halves of the same coin
 Ie. If an event occurs then a certain outcome will happen, else do
something different.
 Ex.
 If it rains, then I will wear a rain coat, else I don’t need a jacket
 Flipping a coin. If it is heads I win, else it is tails I lose(100%
outcomes)
 Code:
Creating a nested decision structure:
if (expression):
statement
else:
statement
 Good Programming: Lining up the else with the
preceding if.
 Common Mistakes: Forgetting the : after the else
Conditionals

More Related Content

Similar to Conditionals

Ite295 excel if-stmtdsmithfinal
Ite295 excel if-stmtdsmithfinalIte295 excel if-stmtdsmithfinal
Ite295 excel if-stmtdsmithfinaldpsmith-dcc
 
4. decision making and some basic problem
4. decision making and some basic problem4. decision making and some basic problem
4. decision making and some basic problemAlamgir Hossain
 
Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)mailund
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 Bdplunkett
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loopsallenbailey
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)Jyoti Bhardwaj
 
Ap Power Point Chpt3
Ap Power Point Chpt3Ap Power Point Chpt3
Ap Power Point Chpt3dplunkett
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentationAkhila B
 
Functional Effects - Part 2
Functional Effects - Part 2Functional Effects - Part 2
Functional Effects - Part 2Philip Schwarz
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loopssaifullahbhatti99
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional StatementsIntro C# Book
 
03a control structures
03a   control structures03a   control structures
03a control structuresManzoor ALam
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUjwala Junghare
 

Similar to Conditionals (20)

jhtp9_ch04.ppt
jhtp9_ch04.pptjhtp9_ch04.ppt
jhtp9_ch04.ppt
 
Ite295 excel if-stmtdsmithfinal
Ite295 excel if-stmtdsmithfinalIte295 excel if-stmtdsmithfinal
Ite295 excel if-stmtdsmithfinal
 
4. decision making and some basic problem
4. decision making and some basic problem4. decision making and some basic problem
4. decision making and some basic problem
 
Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)Chapter 3 introduction to algorithms handouts (with notes)
Chapter 3 introduction to algorithms handouts (with notes)
 
07 flow control
07   flow control07   flow control
07 flow control
 
Lecture 07.pptx
Lecture 07.pptxLecture 07.pptx
Lecture 07.pptx
 
C# conditional branching statement
C# conditional branching statementC# conditional branching statement
C# conditional branching statement
 
Ap Power Point Chpt3 B
Ap Power Point Chpt3 BAp Power Point Chpt3 B
Ap Power Point Chpt3 B
 
M C6java5
M C6java5M C6java5
M C6java5
 
1.4 conditions and loops
1.4   conditions and loops1.4   conditions and loops
1.4 conditions and loops
 
Constructs (Programming Methodology)
Constructs (Programming Methodology)Constructs (Programming Methodology)
Constructs (Programming Methodology)
 
Ap Power Point Chpt3
Ap Power Point Chpt3Ap Power Point Chpt3
Ap Power Point Chpt3
 
Cucumber presentation
Cucumber presentationCucumber presentation
Cucumber presentation
 
Functional Effects - Part 2
Functional Effects - Part 2Functional Effects - Part 2
Functional Effects - Part 2
 
C programming
C programmingC programming
C programming
 
VBscript
VBscriptVBscript
VBscript
 
Conditional statements & Loops
Conditional statements & LoopsConditional statements & Loops
Conditional statements & Loops
 
05. Conditional Statements
05. Conditional Statements05. Conditional Statements
05. Conditional Statements
 
03a control structures
03a   control structures03a   control structures
03a control structures
 
Unit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptxUnit IV Array in VB.Net.pptx
Unit IV Array in VB.Net.pptx
 

More from primeteacher32

More from primeteacher32 (20)

Software Development Life Cycle
Software Development Life CycleSoftware Development Life Cycle
Software Development Life Cycle
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Returning Data
Returning DataReturning Data
Returning Data
 
Intro to Functions
Intro to FunctionsIntro to Functions
Intro to Functions
 
Introduction to GUIs with guizero
Introduction to GUIs with guizeroIntroduction to GUIs with guizero
Introduction to GUIs with guizero
 
Function Parameters
Function ParametersFunction Parameters
Function Parameters
 
Nested Loops
Nested LoopsNested Loops
Nested Loops
 
Conditional Loops
Conditional LoopsConditional Loops
Conditional Loops
 
Introduction to Repetition Structures
Introduction to Repetition StructuresIntroduction to Repetition Structures
Introduction to Repetition Structures
 
Input Validation
Input ValidationInput Validation
Input Validation
 
Windows File Systems
Windows File SystemsWindows File Systems
Windows File Systems
 
Nesting Conditionals
Nesting ConditionalsNesting Conditionals
Nesting Conditionals
 
Intro to Python with GPIO
Intro to Python with GPIOIntro to Python with GPIO
Intro to Python with GPIO
 
Variables and Statements
Variables and StatementsVariables and Statements
Variables and Statements
 
Variables and User Input
Variables and User InputVariables and User Input
Variables and User Input
 
Intro to Python
Intro to PythonIntro to Python
Intro to Python
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Hardware vs. Software Presentations
Hardware vs. Software PresentationsHardware vs. Software Presentations
Hardware vs. Software Presentations
 
Block chain security
Block chain securityBlock chain security
Block chain security
 
Hashes
HashesHashes
Hashes
 

Recently uploaded

VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...Suhani Kapoor
 
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证nhjeo1gg
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一Fs sss
 
Final Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipFinal Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipSoham Mondal
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一Fs
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证obuhobo
 
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一A SSS
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfDivyeshPatel234692
 
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士obuhobo
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...Suhani Kapoor
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...Suhani Kapoor
 
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位obuhobo
 
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012rehmti665
 
Storytelling, Ethics and Workflow in Documentary Photography
Storytelling, Ethics and Workflow in Documentary PhotographyStorytelling, Ethics and Workflow in Documentary Photography
Storytelling, Ethics and Workflow in Documentary PhotographyOrtega Alikwe
 
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一A SSS
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of JobRemote DBA Services
 
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...Suhani Kapoor
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Servicejennyeacort
 

Recently uploaded (20)

VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
VIP Russian Call Girls in Bhilai Deepika 8250192130 Independent Escort Servic...
 
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证
原版快速办理MQU毕业证麦考瑞大学毕业证成绩单留信学历认证
 
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一 定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
定制(UOIT学位证)加拿大安大略理工大学毕业证成绩单原版一比一
 
Final Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management InternshipFinal Completion Certificate of Marketing Management Internship
Final Completion Certificate of Marketing Management Internship
 
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
定制(Waikato毕业证书)新西兰怀卡托大学毕业证成绩单原版一比一
 
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
女王大学硕士毕业证成绩单(加急办理)认证海外毕业证
 
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
办理学位证(Massey证书)新西兰梅西大学毕业证成绩单原版一比一
 
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdfNPPE STUDY GUIDE - NOV2021_study_104040.pdf
NPPE STUDY GUIDE - NOV2021_study_104040.pdf
 
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
内布拉斯加大学林肯分校毕业证录取书( 退学 )学位证书硕士
 
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
VIP Call Girls Firozabad Aaradhya 8250192130 Independent Escort Service Firoz...
 
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
VIP Call Girls Service Saharanpur Aishwarya 8250192130 Independent Escort Ser...
 
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort ServiceYoung Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
Young Call~Girl in Pragati Maidan New Delhi 8448380779 Full Enjoy Escort Service
 
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位
加利福尼亚艺术学院毕业证文凭证书( 咨询 )证书双学位
 
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
Call Girls Mukherjee Nagar Delhi reach out to us at ☎ 9711199012
 
FULL ENJOY Call Girls In Gautam Nagar (Delhi) Call Us 9953056974
FULL ENJOY Call Girls In Gautam Nagar (Delhi) Call Us 9953056974FULL ENJOY Call Girls In Gautam Nagar (Delhi) Call Us 9953056974
FULL ENJOY Call Girls In Gautam Nagar (Delhi) Call Us 9953056974
 
Storytelling, Ethics and Workflow in Documentary Photography
Storytelling, Ethics and Workflow in Documentary PhotographyStorytelling, Ethics and Workflow in Documentary Photography
Storytelling, Ethics and Workflow in Documentary Photography
 
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一
办理学位证(UoM证书)北安普顿大学毕业证成绩单原版一比一
 
do's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Jobdo's and don'ts in Telephone Interview of Job
do's and don'ts in Telephone Interview of Job
 
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
VIP Call Girls in Jamshedpur Aarohi 8250192130 Independent Escort Service Jam...
 
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts ServiceCall Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
Call Girls In Bhikaji Cama Place 24/7✡️9711147426✡️ Escorts Service
 

Conditionals

  • 1.
  • 2.  True or False?  Boolean values are abstract concepts used in computations.  TRUE!  Named in honor of George Boole who invented a system of mathematics in which the abstract concepts of true and false can be used in computations
  • 3.  Sometimes a program needs to ”decide” whether or not to execute certain instructions  All previous instructions have been consecutive (sequence structure), that is:  One  After  The  Other  in the order that they appear.  Now we can add some variability, interactivity, and dynamisms into our applications.
  • 4.  A conditional is what we refer to as a decision structure. A decision is made is based upon a set of rules. We mainly will be working with the if…then.  An If decision executes a set of instructions if a Boolean condition is true  Instruction tests a condition  The condition controls how the application executes  Ex.  If an event occurs then a certain outcome will happen.  If it rains, then I will wear a rain coat.
  • 5.  Conditional arguments are Boolean expressions.  We use relational operators to form Boolean statements.  Operator Meaning  == equal to  < less than  <= less than or equals to  > greater than  >= greater than or equal to  != not equal to  Common Mistake: Confusing = with ==
  • 6.  Code: Creating a decision structure: if (expression): statement  To execute more than one statement in a block they must be indented equally: if (score > 90): grade = 'A' print(“Good Job!n”) print(“Not part of the conditions execution”)  Good Programming: Commenting conditional blocks  Common Mistakes: Forgetting equal indent, forgetting :, forgetting space after if  Good Practices: Use a tab not a space (easier to line up and troubleshoot) Space Indent
  • 7.
  • 8.  Code:  Creating a button object  GPIO.setup(pin# , GPIO.IN)  Using button functions to determine if triggered  if (GPIO.input(pin#) == False): Command Command
  • 9.  We can nest conditional statements to have several decisions structures evaluated within one decision tree.  This allows an application to check multiple situations for a single desired outcome.  With an if statement if it evaluates to true it is true the body statements executed  However, with an else it will execute when the if statement is false  If and else compliment each other  50/50  Two halves of the same coin  Ie. If an event occurs then a certain outcome will happen, else do something different.  Ex.  If it rains, then I will wear a rain coat, else I don’t need a jacket  Flipping a coin. If it is heads I win, else it is tails I lose(100% outcomes)
  • 10.  Code: Creating a nested decision structure: if (expression): statement else: statement  Good Programming: Lining up the else with the preceding if.  Common Mistakes: Forgetting the : after the else