Chapter 1: A Mysterious UFO Appears
It was an ordinary evening. I was sitting peacefully, exploring the world of coding, when suddenly something strange appeared in the sky.
A mysterious UFO!
It had huge letters written on it:
NECOZ
I stared at it for a moment. Before I could even understand what was happening, a bright beam of light came out of the spaceship and pulled me inside.
"HEY! WHERE ARE YOU TAKING ME? I DIDN'T EVEN BUY A TICKET!"
When I finally opened my eyes, I found myself in a completely different world.
There were talking cats, strange robots, flying machines, and creatures I couldn't even identify.
Suddenly, a cat wearing sunglasses approached me.
"Welcome to Necoz!"
I looked at it and asked, "Wait... a talking cat? Is this normal here?"
The cat replied, "Of course! You're the strange one here."
I decided not to argue with a cat.
I asked, "Who rules this place?"
The cat immediately bowed.
"All hail our great King nyaomaru !"
And that was how my unexpected adventure inside the Necoz UFO began.
Chapter 2: King nyaomaru 's Impossible Task
A few minutes later, I was taken to the royal chamber.
King nyaomaru was sitting on a huge golden throne. In front of him was a computer surrounded by hundreds of buttons.
He looked at me and said:
"So, you're our new member? Let's see what you can do!"
I nodded confidently.
He pointed towards a room full of 100 cats.
"I want you to greet every single cat. Say hello to all 100 of them!"
I looked at him.
"Seriously? You want me to say hello 100 times?"
King nyaomaru replied, "Yes! That's your first mission."
I sighed.
"Your Majesty, have you never heard of Python Loops?"
He looked confused.
"Loops? Is that some kind of new spaceship?"
I laughed.
"No, Your Majesty! A loop allows us to repeat a task without writing the same code again and again."
I opened my laptop(I have no laptop😢) and showed him:
for i in range(5): print("Hello NecoZ!") Output:
Hello NecoZ! Hello NecoZ! Hello NecoZ! Hello NecoZ! Hello NecoZ! King nyaomaru jumped out of his throne.
"WHAT?! Five greetings with just three lines of code?"
I replied, "Exactly! That's the magic of loops."
He immediately ordered his royal assistant to cancel the 100-cat greeting duty.
Chapter 3: The For Loop and the Hungry Cats
King nyaomaru had another problem.
He had five cats waiting for food.
"Can you feed all of them?" he asked.
"Of course!" I replied.
I created a list of their names:
cats = ["Milo", "Luna", "Tom", "Kitty", "Leob"] for cat in cats: print(cat, "got food!") Output:
Milo got food! Luna got food! Tom got food! Kitty got food! Leob got food! I explained:
-
catsis a list containing five cat names. -
fortells Python to go through the list. -
catrepresents the current item. -
print()displays the name and message.
The loop takes one cat at a time and performs the same task for each one.
King nyaomaru was impressed.
"So I don't have to write separate instructions for every cat?"
"Exactly!"
Suddenly, Tom raised his paw.
"Excuse me! I received my food, but where is my dessert?"
I looked at King nyaomaru .
"Your Majesty, I think this cat needs a separate food budget!"
Chapter 4: The Magic of range()
King nyaomaru wanted to learn something new.
"Can Python count from 1 to 10?"
I replied, "Of course! We can use range()."
for number in range(1, 11): print(number) Output:
1 2 3 4 5 6 7 8 9 10 I explained:
range(1, 11) generates numbers starting from 1 and ending at 10.
But there's one important thing to remember:
The ending number is not included.
King nyaomaru looked confused.
"Wait! So where did number 11 go?"
I replied:
"Number 11 wasn't invited to the party!"
He nodded seriously.
"Poor number 11."
Chapter 5: The While Loop and the Stubborn Cat
The next morning, King nyaomaru called me again.
"We have a serious problem. There's a cat named Lazy Cat. It keeps asking for food until it gets three meals!"
I looked at the cat.
It was already sleeping beside an empty food bowl.
I said, "This sounds like a perfect situation for a while loop."
I wrote:
food = 0 while food < 3: print("Cat wants food!") food += 1 print("Cat is happy!") Output:
Cat wants food! Cat wants food! Cat wants food! Cat is happy! I explained:
-
food = 0sets the starting value. -
while food < 3is the condition. - The loop continues as long as the condition is True.
-
food += 1increases the value by one each time. - When food becomes 3, the condition becomes False, and the loop stops.
King nyaomaru smiled.
"So the cat gets three meals and finally becomes happy?"
I replied, "Yes, Your Majesty."
Lazy Cat suddenly opened one eye.
"Actually, I was hoping for five meals."
I closed my laptop.
"Your Majesty, I think we have a serious financial problem."
Chapter 6: Infinite Loop – The UFO Disaster!
Suddenly, the spaceship's alarm started ringing.
WARNING! WARNING! SYSTEM OVERLOAD!
A robot was standing in the middle of the room, repeating the same sentence:
"HELLO NECOZ! HELLO NECOZ! HELLO NECOZ!"
King nyaomaru shouted:
"MAKE IT STOP!"
I quickly checked the robot's code.
while True: print("Hello Necoz!") I explained:
"Your Majesty, this is an Infinite Loop!"
"What's that?"
"It's a loop that never stops because its condition is always True."
King nyaomaru looked at the robot.
"So this machine will keep saying Hello forever?"
"Unless we stop it!"
I fixed the code:
count = 0 while count < 5: print("Hello NecoZ!") count += 1 Now the robot would say Hello only five times.
King nyaomaru sighed with relief.
"Thank goodness! I was about to throw this robot into space."
Chapter 7: Break and Continue – The Cat Problem
Just when I thought everything was peaceful, King nyaomaru brought another challenge.
"Five cats are standing in a line. But one of them is extremely naughty. If that cat appears, stop the entire process!"
I replied:
"That's exactly what break does!"
I wrote:
cats = ["Milo", "Luna", "Tom", "Bad Cat", "Leo"] for cat in cats: if cat == "Bad Cat": break print(cat) Output:
Milo Luna Tom I explained:
break immediately stops the entire loop.
King nyaomaru nodded.
"Excellent! Bad Cat has been removed from the operation!"
Then I introduced another concept.
"But what if we don't want to stop the entire loop? What if we just want to skip one cat?"
"How is that possible?" he asked.
I smiled.
"Meet continue!"
cats = ["Milo", "Luna", "Tom", "Bad Cat", "Leo"] for cat in cats: if cat == "Bad Cat": continue print(cat) Output:
Milo Luna Tom Leo I explained:
continue skips the current iteration and moves to the next item.
King nyaomaru laughed.
"So we ignore Bad Cat but continue feeding everyone else?"
"Exactly!"
Bad Cat looked offended.
"That's discrimination!"
I replied, "No, that's Python!"
Chapter 8: The Final Mission
After several days of learning, King nyaomaru decided to test my skills.
He called all five robots into the royal chamber.
"Your final mission is to display every robot's number and name!"
I opened my laptop and used another useful Python tool called enumerate().
robots = ["Robo1", "Robo2", "Robo3", "Robo4", "Robo5"] for number, robot in enumerate(robots, start=1): print(number, robot, "is ready!") Output:
1 Robo1 is ready! 2 Robo2 is ready! 3 Robo3 is ready! 4 Robo4 is ready! 5 Robo5 is ready! I explained:
enumerate() lets us access both the index and the item while looping through a collection.
King nyaomaru stood up from his throne.
"Congratulations! From today, you are officially the Python Loop Expert of Necoz!"
All the cats started cheering.
Even Bad Cat clapped, although it secretly wanted to delete my code.
Chapter 9: A New Adventure Begins
I thought my mission was finally over.
But then King nyaomaru announced:
"Our next mission will be about Python Functions!"
I looked at him and said:
"Wait! Can I get at least one day off?"
He replied:
"Of course! But Lazy Cat will be your replacement."
I immediately opened my laptop.
"NO! I'll take the next mission!"
Everyone started laughing.
And that was how I learned Python Loops inside the mysterious Necoz UFO.
But my adventure was far from over.
There were many more coding mysteries waiting for me.
To be continued... 🛸🐱
🐍 What Did We Learn?
| Python Concept | What It Does |
|---|---|
| Loop | Repeats a task |
| For Loop | Iterates over a sequence |
| While Loop | Runs while a condition is True |
| range() | Generates a sequence of numbers |
| Infinite Loop | Continues without stopping |
| break | Terminates the loop |
| continue | Skips the current iteration |
| enumerate() | Provides both index and item |
Even the smartest king needs a little Python magic! 👑🐍
— A Necoz Member 🛸

