
Q4 LESSON 2: Looping Structures - WHILE and FOR Loops
Presentation
•
Computers
•
7th Grade
•
Easy
Esperanza Sabangan
Used 7+ times
FREE Resource
41 Slides • 20 Questions
1
Q4 LESSON 2-MODULE 2: HANDS ACTIVITY 4.2
Python Activities 8 & 9 - Looping Structures – WHILE Loops and Looping Structures – FOR Loops
2
3
4
Poll
What’s your favorite fast food restaurant?
5
6
There are TWO rules that must hold in playing the game.
“Ready to be riddled?” is a LOGICALBRAIN TEASER PUZZLE GAME. The game will enhance your critical thinking ability.
ALL OF YOU will be the participants and must answer by analyzing the RIDDLE to be shown.
You will be given a duration of 30 seconds to answer.
Let's Get it on Pythons!
7
Open Ended
Five letter word
What five-letter word gets shorter when you add two letters to it?
8
ANSWER: Shorter
9
Open Ended
More is less
The more there is, the less you see. What is it?
10
ANSWER: Fog
11
Open Ended
In the light
I exist only when there is light, but direct light kills me. What am I?
12
ANSWER: A Shadow
13
Open Ended
Face and hands
What has a face and two hands but no arms or legs?
14
ANSWER: A Clock
15
Open Ended
While it dries
What gets wetter while it dries?
16
ANSWER: A Towel
17
Open Ended
Around the world
What travels around the world but stays in the same corner?
18
ANSWER: A Stamp
19
Open Ended
In the planets
You can find it in Mercury, Earth, Mars, Jupiter, and Saturn, but not in Venus or Neptune. What is it?
20
ANSWER: The letter "R"
21
Open Ended
Breaks without fall
What breaks but never falls, and what falls but never breaks?
22
ANSWER: Morning and Night
23
Open Ended
Meeting directions
A woman is a bit confused about where her meeting is. Starting on the fourth floor, she climbs up five stories, down seven stories, up six stories, down three stories, and up four stories again. What floor is she on?
24
ANSWER: The ninth floor
25
Open Ended
The city bus
You’re driving a city bus. At the first stop, five women get on. At the second stop, one woman gets off and two men get on. At the third stop, three children get on. The bus is white and it’s raining outside in March. What color is the bus driver’s hair?
26
ANSWER: Whatever color your hair is. You’re the bus driver.
27
Open Ended
Moving while seated
Who makes moves while sitting down?
28
ANSWER: A chess player.
29
Open Ended
Down and up
I come down, but I never go up. What am I?
30
ANSWER: Rain
31
Open Ended
Make, save, change, raise
People make me, save me, change me, raise me. What am I?
32
ANSWER: Money
33
Open Ended
Always in front
What is always in front of you but can’t be seen?
34
ANSWER: The future
35
Open Ended
Once a minute
What can be seen once in a minute, twice in a moment, and never in a thousand years?
36
ANSWER: The letter “M.”
37
Continuation of Presentation of Learner's Tasks Management System
38
39
Open Ended
How important "Modularizing Code" in programming?
40
Open Ended
How do you write if-else, nested if/else and elif statements in Python and state their importance in programming?
41
42
LOOPING
A looping structure allows a block of code to be repeated one or more times.
43
Why LOOP at all?
The main reason why we need looping in programs is to make complex problems simpler as sometimes we won’t be writing the whole program to go through each query if the functionality is same.
The main advantages of using loops in python is that it saves your time, you don’t have to write the same code every time to perform the same functionality; also loops make your code look clean.
44
Open Ended
What is Loop in Python?
What is the syntax of for loop in Python?
45
WHILE Loop
A while loop in python continues to execute the code as long as the given condition is true, if it becomes false, then the loop stops.
Another reason to use while loop is when we aren’t sure about how many times to iterate.
46
47
WHILE Loop sample program structure
48
Types of WHILE Loop
An Infinite Loop
Be careful while using a while loop. Because if you forget to increment the counter variable in python, or write flawed logic, the condition may never become false.
In such a case, the loop will run infinitely, and the conditions after the loop will starve. To stop execution, press Ctrl+C.
49
Types of WHILE Loop
The else statement for while loop
A while loop may have an else statement after it. When the condition becomes false, the block under the else statement is executed.
However, it doesn’t execute if you break out of the loop or if an exception is raised.
50
Types of WHILE Loop
Single Statement while
Like an if statement, if we have only one statement in while’s body, we can write it all in one line.
You can see that there were two statements in while’s body, but we used semicolons to separate them. Without the second statement, it would form an infinite loop
51
FOR Loop
For loop is a python loop which repeats a group of statements for a given number of times.
It is always a good practice to use the for loop when we know the number of iterations.
52
53
54
Types of FOR Loop
55
Open Ended
How do you write a loop in Python?
How many types of loops are there in Python?
56
LOOP Control Statement
Sometimes, you may want to break out of normal execution in a loop.
For this, we have three keywords in Python- break, continue, and pass.
57
Break Statement
When you put a break statement in the body of a loop, the loop stops executing, and control shifts to the first statement outside it.
You can put it in a for or while loop.
58
Continue Statement
When the program control reaches the continue statement, it skips the statements after ‘continue’.
It then shifts to the next item in the sequence and executes the block of code for it.
You can use it with both for and while loops.
59
Pass Statement
In Python, we use the pass statement to implement stubs.
When we need a particular loop, class, or function in our program, but don’t know what goes in it, we place the pass statement in it.
It is a null statement. The interpreter does not ignore it, but it performs a no-operation (NOP).
60
61
Q4 LESSON 2-MODULE 2: HANDS ACTIVITY 4.2
Python Activities 8 & 9 - Looping Structures – WHILE Loops and Looping Structures – FOR Loops
Show answer
Auto Play
Slide 1 / 61
SLIDE
Similar Resources on Wayground
53 questions
Intro to Probability
Presentation
•
7th Grade
57 questions
PRESENT SIMPLE AFFIRMATIVE
Presentation
•
7th Grade
57 questions
7.Science.U02.L3-5.Heat Transfer
Presentation
•
7th Grade
55 questions
Year 7 Networks Homework 2
Presentation
•
6th Grade
55 questions
Speed
Presentation
•
7th Grade
56 questions
Animal Reproduction
Presentation
•
7th Grade
56 questions
Characteristics of the Election Process
Presentation
•
7th Grade
55 questions
XSEL 2.0 Mathematics Subject Orientation
Presentation
•
7th Grade
Popular Resources on Wayground
20 questions
Math Review
Quiz
•
3rd Grade
15 questions
Fast food
Quiz
•
7th Grade
20 questions
Context Clues
Quiz
•
6th Grade
20 questions
Inferences
Quiz
•
4th Grade
19 questions
Classifying Quadrilaterals
Quiz
•
3rd Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
10 questions
Identify Fractions, Mixed Numbers & Improper Fractions
Quiz
•
3rd - 4th Grade
Discover more resources for Computers
15 questions
Fast food
Quiz
•
7th Grade
10 questions
Candy
Quiz
•
4th - 8th Grade
10 questions
Fact Check Ice Breaker: Two truths and a lie
Quiz
•
5th - 12th Grade
10 questions
Memorial Day History and Traditions
Interactive video
•
5th - 8th Grade
14 questions
Volume of rectangular prisms
Quiz
•
7th Grade
15 questions
Middle School Fun Trivia Questions
Quiz
•
7th - 8th Grade
22 questions
Simple Probability
Quiz
•
7th Grade
10 questions
Video Games
Quiz
•
6th - 12th Grade