![Page 2: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/2.jpg)
Agenda1. Relational operators: >, <, <=, >=, ==, !=
2. The if-elif-else statement
3. Logical operators: and or not
![Page 3: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/3.jpg)
![Page 4: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/4.jpg)
3.1 The if Statement
![Page 5: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/5.jpg)
Program Output
![Page 6: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/6.jpg)
Indentation: Whitespace Matters!1 tab = 4 spaces
![Page 7: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/7.jpg)
Indentation examples
![Page 8: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/8.jpg)
3.2 The if-else Statement
![Page 9: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/9.jpg)
if-else statement
![Page 10: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/10.jpg)
Program output
![Page 11: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/11.jpg)
if-else statement w boolean
![Page 12: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/12.jpg)
if-else statement w boolean, version 2
![Page 13: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/13.jpg)
3.3 String comparison
![Page 14: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/14.jpg)
Program output
![Page 15: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/15.jpg)
String comparison is case sensitive
![Page 16: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/16.jpg)
Program Output
![Page 17: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/17.jpg)
3.5 Logical Operators
Operator Description
and will return true when both conditions are true.
or will return true when at least one condition is true.
not If the condition is true, not operator will make it false.
![Page 18: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/18.jpg)
Logical and
![Page 19: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/19.jpg)
Program output
![Page 20: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/20.jpg)
Logical or
![Page 21: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/21.jpg)
Program output
![Page 22: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/22.jpg)
Operator not
![Page 23: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/23.jpg)
Program output
![Page 24: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/24.jpg)
3.4 The if-elif-else Statement
![Page 25: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/25.jpg)
Testing a series of conditions
![Page 26: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/26.jpg)
Age:infant, child, teenager, adult. Write a program that asks a user to enter a person’s age. The program should then display a message if the person is an infant, child, teenager or adult.
![Page 27: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/27.jpg)
Solution -where’s the bug?
![Page 28: The Statement - GramercyData3.5 Logical Operators Operator Description and will return true when both conditions are true.or will return true when at least one condition is true. not](https://reader035.vdocuments.net/reader035/viewer/2022071514/6134f7aedfd10f4dd73c11cb/html5/thumbnails/28.jpg)
3.4 Nested if-elif-else statements