operators

This commit is contained in:
2025-08-13 00:43:16 +05:30
parent f1047cea6a
commit 4212fbbc7b
3 changed files with 82 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
a = 15
b = 4
# Addition
print("Addition:", a + b) # Addition: 19
# Subtraction
print("Subtraction:", a - b) # Subtraction: 11
# Multiplication
print("Multiplication:", a * b) # Multiplication: 60
# Division
print("Division:", a / b) # Division: 3.75
# Floor Division
print("Floor Division:", a // b) # Floor Division: 3
# Modulus
print("Modulus:", a % b) # Modulus: 3
# Exponentiation
print("Exponentiation:", a ** b) # Exponentiation: 50625
# Comparison Operators in Python
a = 13
b = 33
print(a > b) # False
print(a < b) # True
print(a == b) # False
print(a != b) # True
print(a >= b) # False
print(a <= b) # True
# Logical Operators in Python
a = True
b = False
print(a and b) # False
print(a or b) # True
print(not a) # False
# Assignment Operators in Python
a = 10
b = a
print(b) # 10
b += a
print(b) # 20
b -= a
print(b) # 10
b *= a
print(b) # 100
# Identity Operators in Python
a = 10
b = 20
c = a
print(a is not b) # True
print(a is c) # True
# Ternary Operator in Python
a = 10
b = 20
print("a is greater" if a > b else "b is greater")
# There No ++ and -- Operators in Python

View File

@@ -18,6 +18,11 @@
- Windows/macOS (default FS): `MyFile.py` == `myfile.py`
- Linux: case-sensitive — theyre different files.
---
## 2. PEP 8 Style Recommendations (Best Practices)

View File

@@ -68,3 +68,4 @@ x = "string now" # Allowed
type(x) # <class 'str'>
isinstance(x, str) # True