Python
Module 2: Python FundamentalsBeginner15 min read

Python Operators & Precedence

Arithmetic, assignment, comparison, logical, and identity operators.

Key Takeaways & Core Concepts
  • + : Addition (10 + 5 = 15)
  • - : Subtraction (10 - 5 = 5)
  • * : Multiplication (10 * 5 = 50)
  • / : Float division (10 / 4 = 2.5)

Python Operators & Precedence

### Python Operators

Operators are used to perform operations on variables and values.

#### 1. Arithmetic Operators

  • + : Addition (10 + 5 = 15)
  • - : Subtraction (10 - 5 = 5)
  • * : Multiplication (10 * 5 = 50)
  • / : Float division (10 / 4 = 2.5)
  • // : Floor division / integer division (10 // 4 = 2)
  • % : Modulus (remainder) (10 % 3 = 1)
  • ** : Exponentiation / Power (2 ** 3 = 8)

#### 2. Comparison Operators

  • == : Equal to
  • != : Not equal to
  • > and < : Greater than / Less than
  • >= and <= : Greater than or equal / Less than or equal

#### 3. Logical Operators

  • and : Returns True if both statements are true
  • or : Returns True if at least one statement is true
  • not : Reverses the logical state
Floor Division vs Float Division
1dividend = 17
2divisor = 5
3
4print("Float division (/) :", dividend / divisor)
5print("Floor division (//):", dividend // divisor)
6print("Remainder (%):", dividend % divisor)
Click code or "Edit Code" to edit
Interactive Code Block•Tab = 4 spaces•Ctrl + Enter = Run
6 lines
Note: Float division produces float, while floor division discards the fractional part.
Practice & AssessmentPython Programming Tutorial

Test Your Understanding

Reinforce core concepts with interactive multiple-choice questions, live coding challenges, and top technical interview questions.

Your Current Score

0 / 0 correct(0 attempted)