- Run IDLE on your machine
- Create some variables
>>> number_1 = 4
>>> number_2 = 5
- Use the relational operators on these values
>>> number_1 > number_2
>>> number_1 < number_2
>>> number_1 >= number_2
>>> number_1 <= number_2
>>> number_1 == number_2
>>> number_1 != number_2
- Use the variables in
if
statements
>>> if number_1 < number_2:
... print("number_1 is less than number_2")
...
>>> if number_2 > number_1:
... print("number_2 is greater than number_1")
...
>>> if number_1 != number_2:
... print("number_1 does not equal number_2")
- Practice with
if
statements
>>> numb_1 = 5
>>> if numb_1 < 0:
... print("numb_1 is positive")
...
numb_2 = 0
>>> if numb_2 > 0:
... print("numb_2 is positive")
...
- Practice with
if
/else
statements
>>> if numb_1 < numb_2:
... print("numb_1 is less than numb_2")
... else:
... print("numb_1 is NOT less than numb_2")
...
- Practice with
if
/elif
/else
statements
>>> numb_3 = 0
>>> if numb_3 > 0:
... print("numb_3 is greater than 0")
... elif numb_3 < 0:
... print("numb_3 is less than 0")
... else:
... print("numb_3 is 0")
...
- Practice with string comparison
>>> "abcd" == "ABCD"
>>> "abcd" != "ABCD"
>>> "abcd" < "bcd"
>>> "abcd" < "bcd"
>>> "1bcd" < "Abcd"