1.5.2
Boolean & Assignment Operators 2
Boolean Operators
Boolean Operators
Boolean operators perform logical operations and always result in True or False values.
And
And
- 'and' evaluates to True only if both operands are True.
- True and True = True.
- True and False = False.
- False and True = False.
- False and False = False.
Or
Or
- 'or' evaluates to True if any of the two operands are True:
- True or True = True.
- True or False = True.
- False or True = True.
- False or False = False.
Not
Not
- 'not' negates a logical value.
- not True = False.
- not False = True.
Assignment Operators
Assignment Operators
Assignment operators allow us to give a variable a value, or to update its value.
Assignment
Assignment
- Assignment is done using the = operator. For example:
- x = 50
Updating
Updating
- We can also use special assignment operators to update the value of a variable, for example:
- x += 50 is the same as x = x + 50
- x %= 50 is the same as x = x % 50
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Jump to other topics
1Introduction to Python
1.1Python
1.2Input & Output
1.3Data Types
1.4Variables & Constants
1.6Program Flow
2Data Structures
2.1Lists & Strings
2.2File Handling
3Modularity
3.1Subroutines
3.2Data Flow
4Good Practice
4.1Naming & Whitespace
4.2Comments
4.3Exceptions
Unlock your full potential with GoStudent tutoring
Affordable 1:1 tutoring from the comfort of your home
Tutors are matched to your specific learning needs
30+ school subjects covered