← 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
Ready to go further?

These free tutorials are a preview, our Backend Development cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Backend Development
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account