Please enable JavaScript.
Coggle requires JavaScript to display documents.
If statements and decisions - Coggle Diagram
If statements and decisions
If statements can be used to make decisions in many different occasions
Most of the times, while doing if statements, we use Comparison Operators
These operators are what define if a decision is true or false
Comparison operators are:
The equal sign: ==
The not equal sign: !=
The "greater than" sign: >
The "lower than" sign: <
The "equal to and lower than" sign: <=
The "equal to and greater than" sign: >=
1 more item...
if (Numb1 <= 2 )
if (Numb1 < Numb2)
if (Numb1 > Numb2)
if (Numb1 != 2 )
if (Numb1 == 2 )
While doing if statements, we also use Python Logical Operators
Logical operators are:
the "and" operator
example: if (Numb1 == 2
and
Numb 2 == 3)
the "or" operator
example: if (Numb1 > 2
or
Numb 2 > 3)
the "not" operator
example: if not (Numb1 > 2
or
Numb 2 > 3")
If statements and decisions are crucial to Python coding. They can be used anywhere that the computer is trying to communicate or give a message to the user.
Some examples of this are:
If you would like for the computer to tell you if you've died in a certain game
If you want the computer to solve math equations for you
If you want the computer to help you with monthly bills
If you want the computer to tell when you have accomplished something
These if statements can also be:
"Else"
"Elif"
Allows us to check for multiple expressions
Example:
Elif Numb1 == 10
print ("This is correct")
Catches anything which isn't caught by the previous conditions.
Example:
Else:
print ("Hello")