👋 Work With Me

I help startups and teams build production-ready apps with Django, Flask, and FastAPI.

Let’s Talk →

I'm always excited to take on new projects and collaborate with innovative minds.

Address

No 7 Street E, Federal Low-cost Housing Estate, Kuje, Abuja 903101, Federal Capital Territory

Social Links

Tutorials

Python Tutorial Series – Lesson 3: Operators in Python

Python Tutorial for Beginners (Lesson 3): Learn Python operators with examples, screenshots, and exercises – arithmetic, comparison, logical, and assignment operators.

Python Tutorial Series – Lesson 3: Operators in Python

Welcome back to the Python Tutorial Series for Beginners! 🎉

In Lesson 2, we explored variables and data types in Python.
Now in Lesson 3, we’ll dive into Operators – the tools that allow us to perform calculations, compare values, and build logic in our programs.

By the end of this lesson, you’ll understand:

  • Arithmetic operators (+, -, *, /, etc.)
  • Comparison operators (==, !=, >, <)
  • Logical operators (and, or, not)
  • Assignment operators (+=, -=, etc.)

🔹 What are Operators?

Operators are special symbols or keywords in Python used to perform operations on values and variables.

Think of them like the buttons on a calculator – but more powerful.


🔹 1. Arithmetic Operators

These are used to perform basic math operations:

 
x = 10
y = 3
print(x + y)   # Addition → 13
print(x - y)   # Subtraction → 7
print(x * y)   # Multiplication → 30
print(x / y)   # Division (float) → 3.333...
print(x // y)  # Floor division → 3
print(x % y)   # Modulus (remainder) → 1
print(x ** y)  # Exponent (power) → 1000

VS Code showing arithmetic operations with results
 


🔹 2. Comparison Operators

These are used to compare two values. They return True or False.

 
a = 5
b = 10
print(a == b)   # Equal → False
print(a != b)   # Not equal → True
print(a > b)    # Greater than → False
print(a < b)    # Less than → True
print(a >= 5)   # Greater or equal → True
print(b <= 10)  # Less or equal → True

Terminal showing True:False results of comparisons
 


🔹 3. Logical Operators

Logical operators are used to combine conditions.

 
x = 8
print(x > 5 and x < 10)   # True (both conditions true)
print(x > 10 or x < 5)    # False (neither true)
print(not(x > 5))         # False (because x > 5 is True, so not makes it False)

VS Code showing logical operator examples
 


🔹 4. Assignment Operators

Assignment operators are shortcuts for updating variables.

 
x = 10
x += 5   # Same as x = x + 5 → 15
x -= 3   # Same as x = x - 3 → 12
x *= 2   # Same as x = x * 2 → 24
x /= 4   # Same as x = x / 4 → 6.0

VS Code showing variable value updates
 


🔹 5. Combining Operators in Expressions

You can mix different operators to create more complex expressions.

 
age = 20
is_student = True
print(age > 18 and is_student)   # True
print(age < 18 or is_student)    # True

Terminal showing combined operator results
 


🔹 Exercises for Beginners

Try these in a new Python file (lesson3.py):

  1. Create two variables a = 15 and b = 4. Print their:
    • sum
    • difference
    • product
    • quotient (both / and //)
    • remainder
    • exponent (a ** b)
  2. Check if 25 is greater than 10 and less than 30.
  3. Suppose you have x = 7. Use assignment operators to:
    • Add 3
    • Multiply by 2
    • Subtract 4
  4. Challenge: Write a small program that checks if a person can vote.
    • Variable: age
    • Condition: age must be >= 18
    • Print True if eligible, False if not.

🎯 Recap

In this lesson, you learned:
✅ Arithmetic operators for calculations
✅ Comparison operators for checking conditions
✅ Logical operators for combining conditions
✅ Assignment operators for quick updates

Next up: Lesson 4 – Strings in Python (working with text, string methods, and formatting). ✨

💼 Need a Developer?

I'm Kingsley Odume, a Django, Flask, and FastAPI developer with experience building SaaS platforms, APIs, and modern web apps. If you're a recruiter or business owner looking for a reliable software developer, let's connect!

🚀 Hire Me

3 min read
Aug 20, 2025
By Kingsley Odume
Share

Leave a comment

Your email address will not be published. Required fields are marked *

Related posts

Aug 29, 2025 • 3 min read
Step-by-Step: Building a SaaS App with Django + Stripe Payments

Learn how to build a real-world SaaS app with Django and Stripe paymen...

Aug 21, 2025 • 3 min read
Final Wrap-Up: Python Tutorial Series for Beginners

Congratulations on completing the Python Tutorial Series! 🚀 In this w...

Aug 20, 2025 • 4 min read
Final Lesson: Mini Project – Putting It All Together in Python

In this final lesson, we’ll bring all those concepts together in a Min...

Your experience on this site will be improved by allowing cookies. Cookie Policy