0% found this document useful (0 votes)
2 views

Loops Learning to Repeat!

The document explains the concept of loops in programming, highlighting their purpose of repeating tasks to save time. It covers different types of loops, including For Loops, While Loops, Nested Loops, Do-While Loops, and Infinite Loops, with real-life examples for each. The key takeaway is that loops simplify repetitive tasks in coding.

Uploaded by

Atharv Tiwari
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Loops Learning to Repeat!

The document explains the concept of loops in programming, highlighting their purpose of repeating tasks to save time. It covers different types of loops, including For Loops, While Loops, Nested Loops, Do-While Loops, and Infinite Loops, with real-life examples for each. The key takeaway is that loops simplify repetitive tasks in coding.

Uploaded by

Atharv Tiwari
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 13

LOOPS:

LEARNING TO
REPEAT!
Fun with Python
Programming
e
WHAT IS A LOOP?
• A LOOP IS LIKE REPEATING SOMETHING AGAIN AND
AGAIN.
•• Just like:
• - Tying your shoes.
• - Brushing your teeth every morning.
• Computers use loops to repeat things too!
WHY
USE
LOOPS?
LET'S GET STARTED!
•• To save time!
•• Imagine you want to:
• - Count numbers from 1 to 10.
• - Draw a star 10 times.
•• Instead of saying 'Do it again' every time, we
use loops!
TYPES OF LOOPS
•THERE ARE TWO KINDS OF LOOPS:

1. For Loop:-
When you know how many times to repeat.

2. While Loop:-
When you repeat until something happens.
EXAMPLE: WAVING TO
FRIENDS
IMAGINE YOU SEE 3 FRIENDS ON YOUR WAY TO
SCHOOL, AND YOU WANT TO SAY "HI!" TO EACH
ONE OF THEM.
REAL-LIFE EXAMPLE:
WHILE LOOP
IMAGINE YOU HAVE A PLATE OF COOKIES, AND YOU
WANT TO KEEP EATING UNTIL THE PLATE IS EMPTY.
NESTED LOOPS
A LOOP INSIDE ANOTHER LOOP. IT’S LIKE REPEATING
ONE TASK MANY TIMES INSIDE ANOTHER REPEATED
TASK.
ex: Imagine you want to draw stars (*) on a piece of paper, row by
row. Each row has 5 stars, and you want to draw 3 rows.
INFINITE LOOPS
A LOOP THAT KEEPS GOING FOREVER UNTIL YOU STOP
IT (BY BREAKING IT).
Example: Imagine you’re asking, “Do you want to
play?” repeatedly until someone says “No.”
DO-WHILE LOOP
• A DO-WHILE LOOP IS LIKE TRYING SOMETHING AT LEAST ONCE,
EVEN IF YOU’RE NOT SURE IT’S NEEDED.
• IT’S A LOOP WHERE THE TASK HAPPENS FIRST, AND THEN YOU
CHECK IF YOU NEED TO DO IT AGAIN.

examples:-
• Imagine you have a jar of candy. You’ll always
take and eat one candy even if the jar might
be empty.
• After eating, you check if there are more
candies. If there are, you keep eating.
WHAT DID WE LEARN?
Loops are fun and save
time!
• Loops are like saying 'Do it again!'
• For Loops: Repeat a certain number of times.
• While Loops: Repeat until something happens.
• Nested For Loops: A loop inside another loop. It’s used when you need
to repeat something within another repeated task.
• Do-While Loop: A loop that runs at least once, even if the condition is
false.
• Infinite Loop: A loop that never stops running unless you force it to stop
(with a break).
• It’s used when waiting for something to happen.
THANK YOU!
Any Doubts?

:- Atharv

You might also like