Python Tutorial 0/52 lessons ~6 min read Lesson 8
Operators
Python has the usual arithmetic, comparison, logical, bitwise, and assignment operators — plus identity (is) and membership (in) operators that beginners often confuse with equa…
Course progress0%
Focus
9 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
Python has the usual arithmetic, comparison, logical, bitwise, and assignment operators — plus identity (is) and membership (in) operators that beginners often confuse with equality.
Understanding the topic
Core concepts to understand:
- Arithmetic:
+ - * / // % **. - Comparison:
== != < > <= >=. - Logical:
and or not. - Identity:
is,is not. - Membership:
in,not in.
Syntax reference
Visual flow / code:
python
# Arithmeticprint(7 / 2) # 3.5 (true division)print(7 // 2) # 3 (floor division)print(7 % 2) # 1 (modulo)print(2 ** 10) # 1024 (power)# Identity vs equalitya = [1, 2]b = [1, 2]print(a == b) # True (same value)print(a is b) # False (different objects)# Membershipprint(2 in [1, 2, 3]) # True
Execution workflow
1Operators Workflow
1 / 4Step 1
Arithmetic: + - * / // % **.
Apply this step while implementing operators in real code.
Real-world use
Using is to compare values instead of == is one of the most common beginner bugs — is compares identity, not equality.
Best practices
- Use
==for value comparison. - Use
is None(never== None).
Common mistakes
iswith strings/ints may work due to interning — don't rely on it.
Hands-on exercise
Interview preparation — practice these questions:
isvs==?- What does
//do? - Why
is None?
Summary
In summary: == for values, is for identity. Always is None.
Ready to mark this lesson complete?Track your journey across the entire course.