Learning outcomes
By the end of this chapter, you should be able to:- use assignment and augmented assignment operators
- evaluate multiple/chained assignment correctly
- distinguish identity and equality
- use membership operators with strings/lists
- apply bitwise operators at basic level
30-minute recording plan
0-8 min: assignment and augmented assignment8-14 min: multiple assignment and chained assignment14-19 min: identity vs equality19-24 min: membership operators24-30 min: bitwise basics and exam traps
Assignment operators
+=, -=, *=, /=, //=, %=
Multiple assignment and unpacking
Python can assign multiple variables in one line:ValueError.
Chained assignment (MCQ-critical)
- right-hand side expression is evaluated once (
5) - that value is assigned to all targets (
x,y,z)
x == y == z.
Quiz-style solved snippet
- After line 1:
x = a,y = b,z = c - In line 2, RHS is current value of
z(which isc) - That RHS value is assigned to
xandyas well
x = cy = cz = c
Mutable object trap
Identity operators
is, is not
is mainly for identity checks (for example value is None).
Beginner alert: == vs is rule
Use this rule in beginner code and exams:
- Use
==for value comparison (almost always) - Use
ismainly withNone
x is 5 or name is "Aarav".
Membership operators
in, not in
Bitwise operators (intro)
&, |, ^, ~, <<, >>
Conditional expression (ternary)
Mini showcase: simple permission flags
| and & with compact storage.
Exam-focused points
==checks value equalityischecks object identity- membership is very common in string/list questions
- know at least one solved bitwise example
- in chained assignment, RHS is evaluated once and assigned to all targets
x = y = []creates one shared list object (aliasing trap)
Practice questions
- Show output:
- Predict final values:
- Write program to check if a character is a vowel using
in. - Demonstrate difference between
==andiswith list example.
