Sibling War Made Python Operators Easy!

Nitish kalyanNitish kalyan
8 min read

We often think learning programming is tough, full of complex code and dry examples. But what if I told you that even your daily family drama can teach you Python?

Let me introduce you to Tinku and Chinku, two naughty brothers who turned their fight for snacks into a real-life Python lesson on Operators.

Let The War Begin

Tinku and Chinku — the legendary snack fighters — were at it again. Chocolates and toffees were flying everywhere, and their complaints were louder than a school bell! But their mom, the ultimate problem solver, stepped in.

Little did they know… their silly fight was about to teach them — and us — a real-life lesson in Python Arithmetic Operators!

1. Arithmetic Operators — The Beginning of the Snack Battle

Arithmetic operators are used to perform basic mathematical operations like addition (+), subtraction (-), multiplication (*), division (/), floor division (//), modulus (%), and exponentiation (**).

The war had officially begun…

  • Tinku , always quick on his feet, quietly grabbed 3 chocolates and 7 toffees.

  • Chinku, never one to fall behind, managed to snatch 5 chocolates and 3 toffees for himself.

Soon, their house turned into a mini battlefield of snacks flying everywhere! But as always, their mom came in to restore peace — with maths.

OperatorSymbolMeaning
Addition+Adds two numbers
Subtraction-Subtracts one number from another
Multiplication*Multiplies two numbers
Division/Divides and returns float result
Floor Division//Divides and returns whole part only
Modulus%Returns remainder of division
Exponentiation**Raises first number to power of second

Addition (+) — Mom adds total chocolates

She adds:

  • Tinku’s Chocolates 3 + Chinku’s Chocolates 5 → Total 8

  • Tinku’s Toffees 7 + Chinku’s Toffees 3 → Total 10

Mom smiles, "8 chocolates, 10 toffees…

tinku_chocolates = 3
tinku_toffees = 7
chinku_chocolates = 5
chinku_toffees = 3
total_chocolates = tinku_chocolates + chinku_chocolates
total_toffees = tinku_toffees + chinku_toffees
print(total_chocolates, total_toffees)
8, 10

Subtraction (-) — Tinku eats secretly

Tinku secretly ate 2 chocolates and 4 toffees, but mom noticed:

tinku_ate_chocolates = 2
tinku_ate_toffees = 4
Remaining_chocolates = total_chocolates - tinku_ate_chocolates
Remaining_toffees = total_toffees - tinku_ate_toffees
print(Remaining_chocolates, Remaining_toffees)
6, 6

Multiplication (*) — Papa doubles snacks

The chaos got so loud that their dad couldn’t handle it anymore. Dad declared, “Enough! Let me double everything, so no one fights!”

final_total_chocolates = Remaining_chocolates * 2
final_total_toffees = Remaining_toffees * 2
print(final_total_chocolates, final_total_toffees)
12, 12

Division (/) — Fair Sharing Between Brothers

With so many snacks, Chinku demanded, “We share everything equally, or this war isn’t over!”

chocolates_per_child = final_total_chocolates / 2
toffees_per_child = final_total_toffees / 2
print(chocolates_per_child, toffees_per_child)
6.0, 6.0

Floor Division (//) — Whole snacks only

Just when Tinku and Chinku thought their fight was under control, their elder sister stepped in — with her own evil plan!

She quietly added 3 extra chocolates and 3 toffees, just to spice things up and enjoy the drama.

But their mom, always alert, wanted to divide the snacks fairly — but only whole snacks count, no half chocolates allowed! That’s where Floor Division (//) comes in.

final_total_chocolates += 3  # Now 15
final_total_toffees += 3     # Now 15
chocolates_per_child = final_total_chocolates // 2
toffees_per_child = final_total_toffees // 2
print(chocolates_per_child, toffees_per_child)
 7, 7

Using // Floor Division:

  • Only whole snacks are divided — fractions ignored.

  • So, each child gets 7 chocolates, 7 toffees, and the leftover? Well… the fight for that leftover starts again!

Modulus (%) — Leftover count

Tinku and Chinku's elder sister succeeded — the fight wasn’t over yet!

After fair sharing, 1 chocolate and 1 toffee were still leftover — the reason? That sneaky remainder!

Mom used the Modulus Operator % to calculate exactly how many snacks were leftover after the division.

leftover_chocolates = final_total_chocolates % 2
leftover_toffees = final_total_toffees % 2
print(leftover_chocolates, leftover_toffees)
1, 1

Exponentiation (**) — Snack Magic

After the snack war, here’s where things stood:

  • 1 leftover chocolate

  • 1 leftover toffee

Both lying on the table, both brothers eyeing them like lions ready to pounce.

Now, Father stepped in, picked up both leftover snacks together and smiled,
"Instead of fighting, let's apply some exponential magic — Python style!"

total_items = leftover_chocolates + leftover_toffees  # 2
power = 3
final_items = total_items ** power
print(final_items)
8

No more fighting, just a pile of delicious snacks ready to be shared.

Now, I think you’re getting familiar with the Python syntax — variables, operators, print statements — so let’s deep dive into the other operators a little faster, but with the same fun, real-life sibling drama!

2. Comparison Operators — Who Has More?

These operators compare two values and return either True or False based on the condition. Examples include greater than (>), less than (<), equal to (==), etc.

In every sibling fight, the most common thing is comparison —

  • "Who has more chocolates?"

  • "Who got extra toffees?"

In Python, just like in real life, Comparison Operators help us compare two things and decide the truth.

Comparison Operators compare values and return either True or False based on the condition:

OperatorMeaningExample
>Greater Than5 > 3 → True
<Less Than2 < 5 → True
==Equal To4 == 4 → True
!=Not Equal To3 != 2 → True
>=Greater Than or Equal To5 >= 5 → True
<=Less Than or Equal To3 <= 4 → True
tinku_chocolates = 7
chinku_chocolates = 7

print(tinku_chocolates > chinku_chocolates)   # False
print(tinku_chocolates == chinku_chocolates)  # True
False  
True

3. Assignment Operators — Quick Adjustments

Assignment operators are used to assign values to variables or update existing values quickly, such as =, +=, -=, *=, /=, etc.

OperatorExampleMeaning
=x = 5Assign value to variable
+=x += 2Add & update (x = x + 2)
-=x -= 1Subtract & update
*=x *= 3Multiply & update
/=x /= 2Divide & update
total_chocolates = 10

total_chocolates += 5  # Mom adds 5 chocolates
total_chocolates -= 2  # Chinku eats 2 chocolates

print(f"Chocolates left: {total_chocolates}")
Chocolates left: 13

4. Logical Operators — Fight Conditions

Logical operators help combine multiple conditions and return True or False based on logical relations like AND, OR, NOT.

OperatorMeaningExample
andBoth conditions trueTrue and False → False
orAt least one trueTrue or False → True
notReverse the truthnot True → False
enough_snacks = True
fight_stopped = False

# Logical AND
print(enough_snacks and fight_stopped)  # False

# Logical OR
print(enough_snacks or fight_stopped)   # True

# Logical NOT
print(not enough_snacks)                # False
False
True
False

5. Bitwise Operators — Dad's Secret Tech Trick

Bitwise operators perform operations on binary bits of numbers — works at a low level, perfect for hidden calculations.

OperatorExampleMeaning
&x & yBitwise AND
```x
^x ^ yBitwise XOR
~~xBitwise NOT
x = 3  # Binary: 011
y = 2  # Binary: 010

print(x & y)  # AND → 010 → 2
print(x | y)  # OR  → 011 → 3
print(x ^ y)  # XOR → 001 → 1
print(~x)     # NOT → Inverts bits
2
3
1
-4

6. Identity Operators — Same Snacks or Different?

Identity operators check whether two variables refer to the same memory location, not just same value.

OperatorMeaningExample
isSame objectsnack1 is snack3 → True
is notDifferent objectsnack1 is not snack2 → True
snack1 = [1, 2, 3]
snack2 = [1, 2, 3]
snack3 = snack1

print(snack1 is snack3)   # True — Same object
print(snack1 is snack2)   # False — Different objects
True
False

7. Membership Operators — Snacks in Box?

Membership operators check if an element exists within a sequence like a list, string, or set.

OperatorMeaningExample
inPresent"chocolate" in box
not inNot present"juice" not in box
snack_box = ["chocolate", "toffee", "biscuit"]

print("chocolate" in snack_box)  # True
print("juice" not in snack_box)  # True
True
True

Summary

Operator TypeSymbol/ExampleMeaning/Use
Arithmetic+, -, *, /, //, %, **Perform basic math operations like add, subtract, multiply, divide, floor divide, modulus, exponentiation.
Assignment=, +=, -=, *=, /=, etc.Assign or update values of variables quickly.
Comparison>, <, ==, !=, >=, <=Compare two values, returns True or False.
Logicaland, or, notCombine multiple conditions logically.
Bitwise&, `, ^, ~, <<, >>`
Identityis, is notCheck if two variables are the same object in memory.
Membershipin, not inCheck if a value exists within a sequence.

"And that’s how a simple snack fight turned into the sweetest Python lesson ever! Next time you grab a chocolate, remember — even snacks follow Python rules."

10
Subscribe to my newsletter

Read articles from Nitish kalyan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nitish kalyan
Nitish kalyan