🔀 ConditionalsNovember 30, 2016
- I can write conditionals in Python using
- I can predict the output of conditionals in Python.
Do Now (in Classroom)
What data type is required for a conditional?
if #something true # run this indented code else: #run this indented code
# What's the difference between school = "F&T" #and 223 == 223 # what about... 223 = "F&T"
Python Comparison Operators
|!||not equal to||
|>=||greater than or equal to||
|<=||less than or equal to||
""" What will print after each conditional is run? """ # Number 1: if 5<2: print("I am right") else: print("I am wrong") # Number 2: if 5>2: print("I am right") else: print("I am wrong")
How can we tell if a number is even or odd?
This is not the percentage sign. I mean, it is, but in Python, it means modulo or mod. What?
It divides one number by another and returns the remainder. Like this:
print(4 % 3) print(1040934 % 2) print(1040934 % 2)
Before you start calculating, what are the only possibilities of each modulo operation?
"String Methods" (or submit in repl):