Page 247 - CTS - CSA TP - Volume 2
P. 247
COMPUTER SOFTWARE APPLICATION - CITS
less_equal = x <= y # Less than or equal to
# Print each result on a separate line
print(f”Equals: {equals}”)
print(f”Not Equals: {not_equals}”)
print(f”Greater Than: {greater_than}”)
print(f”Less Than: {less_than}”)
print(f”Greater Equal: {greater_equal}”)
print(f”Less Equal: {less_equal}”)
Output:
Explanation:
Here, we declare two variables x and y with values 10 and 20, respectively. Then, we use comparison operators
to compare these values.
• equals: Checks if x is equal to y. If true, equals will be True, otherwise False.
• not_equals: Checks if x is not equal to y. If true, not_equals will be True, otherwise False.
• greater_than: Checks if x is greater than y. If true, greater_than will be True, otherwise False.
• less_than: Checks if x is less than y. If true, less_than will be True, otherwise False.
• greater_equal: Checks if x is greater than or equal to y. If true, greater_equal will be True, otherwise False.
• less_equal: Checks if x is less than or equal to y. If true, less_equal will be True, otherwise False.
TASK 4: Logical Operators
Code:
# Logical Operators
a = True
b = False
logical_and = a and b # Logical AND
logical_or = a or b # Logical OR
logical_not = not a # Logical NOT
# Print each result on a separate line
print(f”Logical AND: {logical_and}”)
print(f”Logical OR: {logical_or}”)
print(f”Logical NOT: {logical_not}”)
Output:
232
CITS : IT & ITES - Computer Software Application - Exercise 123