Python Basics – Day Notes
1. Operators
Operators are symbols used to perform operations on values.
Types of Operators
Arithmetic, Comparison, Logical, Assignment, Membership, Identity
2. Logical Operators
Logical operators are used to combine conditions and return True or False.
AND Operator
Returns True only if both conditions are True.
marks = 80
attendance = 85
if marks >= 50 and attendance >= 75:
print('Eligible')
OR Operator
Returns True if at least one condition is True.
age = 16
with_parent = True
if age >= 18 or with_parent:
print('Allowed')
NOT Operator
Reverses the result. True becomes False and False becomes True.
is_logged_in = False
if not is_logged_in:
print('Please login')
3. Comparison Operators
Used to compare two values and return True or False.
print(10 > 5)
print(5 == 5)
4. Conditional Statements
Used to make decisions based on conditions.
IF Statement
age = 20
if age >= 18:
print('Adult')
IF-ELSE Statement
age = 16
if age >= 18:
print('Adult')
else:
print('Minor')
ELIF Statement
marks = 75
if marks >= 90:
print('A')
elif marks >= 50:
print('Pass')
else:
print('Fail')