Download presentation
Presentation is loading. Please wait.
Published byIvan Irawan Modified over 6 years ago
1
Nate Brunelle Today: Conditional Decision Statements
CS1110 Nate Brunelle Today: Conditional Decision Statements
2
Florence
3
Questions?
4
Last Time If, elif, else
5
Conditional decision Statement
if boolean expression: action Elif boolean expression: another action else: yet another action 0 or more 0 or 1
6
Values and Types (not exhaustive)
Operators -50 ,0 ,5, 30, 512 int 3+7, 3*7, 3-7, 3/7 0.5, 1.2, float +, *, -, /, //, %, **, compare ‘hi’, “hi”, ‘hello world! ✃’ str +, * int Print, input function print() True, False bool and, or, not
7
and, or, not examples x<2 and x>0 x<0 or x>2 not x>2
When all things are true x<0 or x>2 When any of the things are true not x>2 When the thing is false
8
and, or, not and or not True if all things are True
False if any things are False or True if any things are True False if all things are False not True if the thing was False False if the thing was True
9
Year is divisible by 4 Unless divisible by 100 Unless divisible by 400 Div400 or (div4 and not div100)
10
“Truthiness” of all things in python
“Truish” Things “Falsish” things True False “True” 1, -1 0.0 None “ “ Empty things “False” ‘’ “” Advice: make sure every and, or has a bool on both sides
11
What do and, or evaluate to?
Evaluate to the first truish thing If all things are falsish, give the last falsish thing And Give the first falsish thing If all things are truish, give the last truish thing
12
Chained Comparitors 1 < 2 < 3 1 < 2 and 2 < 3
True 1 < 2 < 3 1 < 2 and 2 < 3 1 < 2 > 0 < 8 > -5 == -5 Gives true True
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.