Curriculum / Python / Lesson 04

Operators in Python

Python has the familiar arithmetic and comparison operators, but uses readable English keywords — and, or, not — instead of symbols for logical operations.

4 of 11
beginner 📖 5 min read 🎯 1 question

Operators

Python has the familiar arithmetic and comparison operators, but uses readable English keywords — and, or, not — instead of symbols for logical operations. Python also adds ** for exponentiation and // for floor (integer) division.

💡 Key insight Python's // operator always rounds down (floors) the result, even for negative numbers — a subtle detail worth remembering.

Syntax

syntax
a + b   a - b   a * b   a / b   a % b   a ** b   a // b
a == b  a != b  a > b   a < b
a and b   a or b   not a

Example

** raises a number to a power; // divides and rounds down to the nearest whole number.

py
a = 10
b = 3
print("Sum:", a + b)
print("Power:", a ** 2)
print("Floor div:", a // b)
print("Is greater:", a > b)
outputSum: 13 Power: 100 Floor div: 3 Is greater: True

Try it yourself

Copy this example into the Python compiler and run it — try changing a value and see what happens.

Quick Quiz

1. In Python, what does the // operator do?

Back to curriculum