-
Notifications
You must be signed in to change notification settings - Fork 1
Control Flow
Dave Luk edited this page Dec 25, 2017
·
7 revisions
In this lesson, we will learn about ways to control how a program behave.
Boolean is a kind of datatype. It have only two values: True
and False
.
Now you can think of your true-false questions on your tests as booleans!
Boolean operators are symbols that will give us results in boolean. Let's first introduce them:
This is used to check if 2 variable/values are same. For example:
5 == 5 # This give us True
5 == 0 # This give us False
Just like equals, this checks for exact opposite of equals:
5 != 5 # This give us False
5 != 0 # This give us True
This checks for if a value/variable is greater than another:
5 > 5 # This give us False
5 > 0 # This give us True
This checks for if a value/variable is less than another:
5 < 5 # This give us False
0 < 5 # This give us True
This checks for if a value/variable is greater than or equals another:
5 >= 5 # This give us True
0 >= 5 # This give us False
This checks for if a value/variable is less than or equals another:
5 <= 5 # This give us True
0 <= 5 # This give us True