← Python tutorial

Python

Operators

Arithmetic operators (+ - * /) do math, and // and % give integer division and remainder.

Example: the two kinds of division

print(7 / 2)   # 3.5   — normal division, always returns a float
print(7 // 2)  # 3     — integer division, drops the remainder
print(7 % 2)   # 1     — the remainder itself

score = 85
passed = score >= 50 and score <= 100
print("Passed:", passed)

and, or, and not are Python's logical operators — spelled out as words rather than symbols like &&/|| in many other languages, which is part of what gives Python its readable feel.

Example
score = 85
passed = score >= 50 and score <= 100
print("Passed:", passed)
Output
Passed: True