OPERATORS IN PYTHON PROGRAMMING
1. Arithmetic Operators:
- Arithmetic operators are used to perform mathematical
operations on numeric values.
- Examples include addition (`+`), subtraction (`-`), multiplication
(`*`), division (`/`), modulus (`%`), and exponentiation (`**`).
# Arithmetic operators
x = 10
y=3
print(x + y) # Output: 13
print(x - y) # Output: 7
print(x * y) # Output: 30
print(x / y) # Output: 3.3333333333333335
print(x % y) # Output: 1
print(x ** y) # Output: 1000
2. Logical Operators:
- Logical operators are used to perform logical operations on
boolean values (`True` or `False`).
- Examples include logical AND (`and`), logical OR (`or`), and
logical NOT (`not`).
- Example code:hjnuuuuuuuuuuuuuuuuuuuuuuuun
# Logical operators
OPERATORS IN PYTHON PROGRAMMING
x = True
y = False
print(x and y) # Output: False
print(x or y) # Output: True
print(not x) # Output: False
3. Conditional Operators (Comparison Operators):
- Conditional operators are used to compare values and return a
boolean result.
- Examples include equal to (`==`), not equal to (`!=`), greater than
(`>`), less than (`<`), greater than or equal to (`>=`), and less than or
equal to (`<=`).
- Example code:
# Conditional operators
x = 10
y=5
print(x == y) # Output: False
print(x != y) # Output: True
print(x > y) # Output: True
print(x < y) # Output: False
print(x >= y) # Output: True
print(x <= y) # Output: False
OPERATORS IN PYTHON PROGRAMMING
These operators are fundamental in Python programming and are
used extensively to perform various operations, control program
flow, and make decisions based on conditions.