TGViewer
Data Science & Machine Learning Data Science & Machine Learning @datasciencefun ยท 77.8K subscribers
Post #4417 2.39K
๐Ÿš€ Data Science Roadmap 2026

๐Ÿ“˜ Phase 1: Programming Fundamentals

๐Ÿ Topic 2: Python Operators

In the previous lesson, you learned about Variables & Data Types. Now it's time to learn how Python performs calculations, comparisons, and logical operations using operators.

Operators are one of the most fundamental concepts in Python. You'll use them in almost every program, from simple calculations to complex Machine Learning algorithms.

๐Ÿ”น 1. What are Operators?

Operators are special symbols used to perform operations on variables and values.

Example:

a = 10
b = 5
print(a + b)


Output:

15  


Here, "+" is an operator that adds two numbers.

๐Ÿ”น 2. Types of Operators in Python

Python has several types of operators:

โœ… Arithmetic Operators

โœ… Comparison Operators

โœ… Assignment Operators

โœ… Logical Operators

โœ… Membership Operators

โœ… Identity Operators

๐Ÿ”น 3. Arithmetic Operators โญ

Used for mathematical calculations.

Operators:

โ€ข ** + Addition**: 10 + 5 = 15

โ€ข - Subtraction: 10 - 5 = 5

โ€ข ** Multiplication*: 10 * 5 = 50

โ€ข / Division: 10 / 5 = 2.0

โ€ข // Floor Division: 10 // 3 = 3

โ€ข % Modulus (Remainder): 10 % 3 = 1

โ€ข ** Exponent: 2 ** 3 = 8

Example:

a = 10
b = 3
print(a + b)
print(a - b)
print(a * b)
print(a / b)
print(a // b)
print(a % b)
print(a ** b)


๐Ÿ”น 4. Comparison Operators โญ

Used to compare two values. The result is always True or False.

Operators:

โ€ข == Equal to

โ€ข != Not Equal to

โ€ข > Greater than

โ€ข < Less than

โ€ข >= Greater than or Equal to

โ€ข <= Less than or Equal to

Example:

x = 20
y = 10
print(x > y)
print(x == y)
print(x != y)


Output:

True  
False
True


๐Ÿ”น 5. Assignment Operators

Used to assign values to variables.

x = 10
x += 5
print(x)


Output:

15


Other assignment operators:

x -= 2  
x *= 3
x /= 2


๐Ÿ”น 6. Logical Operators โญ

Used to combine multiple conditions.

and

Returns True only if both conditions are True.

age = 25
print(age > 18 and age < 30)


Output:

True


or

Returns True if at least one condition is True.

print(age < 18 or age < 30)


Output:

True


not

Reverses the result.

print(not(age > 18))


Output:

False


๐Ÿ”น 7. Membership Operators

Used to check whether a value exists in a sequence.

in

fruits = ["Apple", "Banana", "Mango"]
print("Apple" in fruits)


Output:

True


not in

print("Orange" not in fruits)


Output:

True


๐Ÿ”น 8. Identity Operators

Used to check whether two variables refer to the same object.

is

a = [1, 2]
b = a
print(a is b)


Output:

True


is not

x = [1, 2]
y = [1, 2]
print(x is not y)


Output:

True


๐Ÿ”น 9. Operator Precedence

Python follows the PEMDAS/BODMAS rule while evaluating expressions.

Example:
  • โค 5
  • ๐Ÿ‘ 1
More from @datasciencefun
  1. Oct 7, 2026ORDER BY salary DESC LIMIT 5; Mistake 3 โ€” Forgetting that LIMIT applies after sorting Forโ€ฆ
  2. Oct 7, 2026๐Ÿš€ Data Science Roadmap 2026 ๐Ÿ“ Phase 3: SQL for Data Science ๐Ÿ“– Topic 4 โ€” LIMIT LIMIT isโ€ฆ
  3. Oct 7, 2026๐Ÿš€๐—ฃ๐—ฎ๐˜† ๐—”๐—ณ๐˜๐—ฒ๐—ฟ ๐—ฃ๐—น๐—ฎ๐—ฐ๐—ฒ๐—บ๐—ฒ๐—ป๐˜ ๐—ง๐—ฟ๐—ฎ๐—ถ๐—ป๐—ถ๐—ป๐—ด | ๐—•๐—ฒ๐—ฐ๐—ผ๐—บ๐—ฒ ๐—ฎ ๐—™๐˜‚๐—น๐—น๐˜€๐˜๐—ฎ๐—ฐโ€ฆ
  4. Oct 7, 2026๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ฃ๐—ผ๐˜„๐—ฒ๐—ฟ ๐—•๐—œ ๐—ณ๐—ผ๐—ฟ ๐—™๐—ฅ๐—˜๐—˜! ๐Ÿ”ฅ Learn Power BI through these FREE learninโ€ฆ
  5. Oct 2, 2026Data Visualisation tips for beginners
  6. Sep 29, 2026๐—™๐—ฅ๐—˜๐—˜ ๐—ฅ๐—ฒ๐˜€๐—ผ๐˜‚๐—ฟ๐—ฐ๐—ฒ๐˜€ ๐—ง๐—ผ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป ๐—”๐—œ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ๐Ÿš€ โ€‹ Explore 6 free resourceโ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’