Search Header Logo
Q4 LESSON 2: Looping Structures - WHILE and FOR Loops

Q4 LESSON 2: Looping Structures - WHILE and FOR Loops

Assessment

Presentation

Computers

7th Grade

Easy

Created by

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

media

2

media

3

media

4

Poll

Question image

What’s your favorite fast food restaurant?

5

media

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

Question image

Five letter word


What five-letter word gets shorter when you add two letters to it?

8

ANSWER: Shorter

media

9

Open Ended

Question image

More is less


The more there is, the less you see. What is it?

10

ANSWER: Fog

media

11

Open Ended

Question image

In the light


I exist only when there is light, but direct light kills me. What am I?

12

ANSWER: A Shadow

media

13

Open Ended

Question image

Face and hands


What has a face and two hands but no arms or legs?

14

ANSWER: A Clock

media

15

Open Ended

Question image

While it dries


What gets wetter while it dries?

16

ANSWER: A Towel

media

17

Open Ended

Question image

Around the world


What travels around the world but stays in the same corner?

18

ANSWER: A Stamp

media

19

Open Ended

Question image

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"


media

21

Open Ended

Question image

Breaks without fall


What breaks but never falls, and what falls but never breaks?

22

ANSWER: Morning and Night

media

23

Open Ended

Question image

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

media

25

Open Ended

Question image

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.

media

27

Open Ended

Question image

Moving while seated


Who makes moves while sitting down?

28

ANSWER: A chess player. 

media

29

Open Ended

Question image

Down and up


I come down, but I never go up. What am I?

30

ANSWER: Rain

media

31

Open Ended

Question image

Make, save, change, raise


People make me, save me, change me, raise me. What am I?

32

ANSWER: Money

media

33

Open Ended

Question image

Always in front


What is always in front of you but can’t be seen?

34

ANSWER: The future

media

35

Open Ended

Question image

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.”

media

37

Continuation of Presentation of Learner's Tasks Management System

media

38

media

39

Open Ended

Question image

How important "Modularizing Code" in programming?

40

Open Ended

Question image

How do you write if-else, nested if/else and elif statements in Python and state their importance in programming?

41

media

42

LOOPING

A looping structure allows a block of code to be repeated one or more times. 

media

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.

media

46

media

47

WHILE Loop sample program structure

media

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.

media

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.

media

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

media

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.

media

52

media

53

media

54

Types of FOR Loop

media

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.

media

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.

media

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.

media

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).

media

60

media

61

media

Q4 LESSON 2-MODULE 2: HANDS ACTIVITY 4.2

Python Activities 8 & 9 - Looping Structures – WHILE Loops  and Looping Structures – FOR Loops

media

Show answer

Auto Play

Slide 1 / 61

SLIDE