Page 428 - CITS - Computer Software Application -TT
P. 428
COMPUTER SOFTWARE APPLICATION - CITS
else:
print(“b is not greater than a”)
Evaluate Values and Variables
The bool() function allows you to evaluate any value, and give you True or False in return,
Example:
Evaluate a string and a number:
print(bool(“Hello”))
print(bool(15))
Example:
Evaluate two variables:
x = “Hello”
y = 15
print(bool(x))
print(bool(y))
ALSO READ:
Python Operators
Operators are special symbols that perform operations on variables and values.
Example:
print(5 + 6) # 11
Here, + is an operator that adds two numbers: 5 and 6.
Types of Python Operators
There are 7 types of Python operators...
1 Arithmetic Operators
2 Assignment Operators
3 Comparison Operators
4 Logical Operators
5 Bitwise Operators
6 Identity Operators
7 Membership Operators
1 Python Arithmetic Operators
Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication, etc.
Example:
sub = 10 - 5 # 5
Here, - is an arithmetic operator that subtracts two values or variables.
2 Python Assignment Operators
Assignment operators are used to assign values to variables. For example,
# assign 5 to x
415
CITS : IT&ITES - Computer Software Application - Lesson 120 - 137 CITS : IT&ITES - Computer Software Application - Lesson 120 - 137