So far weโve seen data in 3 forms:
Datatype | Example | Explanation |
---|---|---|
Numbers | yourAverage = 3.8 |
Integers or floats |
Strings | myName = "Ben" |
Anything inside โquotesโ |
Booleans | isItSaturday = False |
true or false |
Conditional (n) : a statement that is true IF something else is true โIfโฆthenโฆโ statements
In programming:
If this functions, do _____
**Else**, do _____
In life:
If you do your homework, then you will earn a high grade.
Else, you will earn a low grade.
if #something true:
# run this code
else:
#run this code
Booleans!
"""
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"
Comparison | Symbol |
---|---|
Equal to | == |
Not equal to | != |
Less than | < |
Less than or equal to | <= |
Greater than | > |
Greater than or equal to | >= |