Search Header Logo
LESSON 6: Text Files and Nesting Looping Structures & List

LESSON 6: Text Files and Nesting Looping Structures & List

Assessment

Presentation

Computers

7th Grade

Practice Problem

Easy

Created by

Esperanza Sabangan

Used 8+ times

FREE Resource

54 Slides • 14 Questions

1

Q4 LESSON 3:

HANDS-ON ACTIVITY 4.3



Python Activity 10: Files and Nesting Looping Structures

Python Activity 11: Part A – Lists 

media

2

media

3

Open Ended

Question image

If YOU had the "World’s Attention" for 30 seconds, What would YOU say?

4

media

5

There are TWO rules that must hold in playing the game.

  • “Ready to be riddled?” is a LOGICAL BRAIN TEASER PUZZLE GAME. This activity 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!

6

Open Ended

Question image

What 4-letter word can be written forward, backward or upside down, and can still be read from left to right?

7

ANSWER: NOON

media

8

Open Ended

Question image

Which tire doesn’t move when a car turns right?

9

ANSWER: A spare tire

media

10

Open Ended

Question image

What fastens two people yet touches only one?

11

ANSWER: A wedding ring.

media

12

Open Ended

Question image

How can a man who shaves several times a day still sport a long beard?

13

ANSWER: He’s a barber. 

media

14

Open Ended

Question image

What do an island and the letter “t” have in common?

15

ANSWER: They are both in the middle of water. 

media

16

Open Ended

Question image

You’re in a dark room with a candle, a wood stove, and a gas lamp. You only have one match, so what do you light first?

17

ANSWER: The MATCH.

media

18

Open Ended

Question image

Which three letters can frighten a thief away?

19

ANSWER: ICU

media

20

Open Ended

Question image

A red house is made from red bricks. A blue house is made from blue bricks. A yellow house is made from yellow bricks. What is a green house made from?

21

ANSWER: GLASS

media

22

Open Ended

Question image

Four cars come to a four-way stop, all coming from a different direction. They can’t decide who got there first, so they all go forward at the same time. They do not crash into each other, but all four cars go. How is this possible?

23

ANSWER: They all made right-hand turns.

media

24

Open Ended

Question image

An elevator is on the ground floor. There are five people in the elevator including me. When the lift reaches the first floor, one person gets out and two people get in. The lift goes up to the second floor, three people get out, five people get in. It then goes up to the next floor up, no-one gets out but 12 people get in. Halfway up to the next floor up the elevator cable snaps, it crashes to the floor. Everyone else dies in the elevator except me. How did I survive?

25

ANSWER: I got off on the first floor. 

media

26

media

27

Open Ended

Question image

Why is iteration/looping important?

28

Multiple Choice

Which of the following best describes the purpose of a for loop?

1

A for loop is for doing something an indeterminate number of times.

2

A for loop is doing something an infinite number of times.

3

A for loop is for doing something a fixed number of times.

4

A for loop is for doing something three times.

29

Multiple Choice

The condition for a while loop to continue could include which of the following?

1

While something equals something

2

While something is greater than something

3

While something is True

4

All of these

30

media

31

media

32

Nested Loop

  • A nested loop is a loop inside the body of the outer loop. The inner or outer loop can be any type, such as a while loop or for loop. For example, the outer for loop can contain a while loop and vice versa.

  • The outer loop can contain more than one inner loop. There is no limitation on the chaining of loops.

  • In the nested loop, the number of iterations will be equal to the number of iterations in the outer loop multiplied by the iterations in the inner loop.

33

​NESTED FOR LOOP - Syntax of using a nested for loop in Python

media

34

​NESTED FOR LOOP - Syntax of using a nested for loop in Python

media

In this program, the outer for loop is iterate numbers from 1 to 10. The range() return 10 numbers. So total number of iteration of the outer loop is 10.

In the first iteration of the nested loop, the number is 1. In the next, it 2. and so on till 10.

Next, For each iteration of the outer loop, the inner loop will execute ten times. The inner loop will also execute ten times because we are printing multiplication table up to ten.

35

​NESTED FOR LOOP - Syntax of using a nested for loop to print pattern

media

In this program, the outer loop is the number of rows print. 

The number of rows is five, so the outer loop will execute five times

Next, the inner loop is the total number of columns in each row.

For each iteration of the outer loop, the columns count gets incremented by 1

In the first iteration of the outer loop, the column count is 1, in the next it 2. and so on.

The inner loop iteration is equal to the count of columns.

36

​NESTED FOR LOOP - Syntax of using a nested for loop to print pattern

media

37

​NESTED WHILE LOOP - Syntax of using a nested WHILE loop

media

38

​NESTED WHILE LOOP - Syntax of using a nested WHILE in FOR loop

media

39

​NESTED WHILE LOOP - Syntax of using a nested FOR in WHILE loop

media

40

BREAK NESTED LOOP SAMPLE

media

41

CONTINUE NESTED LOOP SAMPLE

media

42

NESTED LOOP USING LIST SAMPLE

media

43

NESTED LOOP USING LIST SAMPLE

media

44

LISTS IN PYTHON

media

45

PROPERTIES OF A LIST

  • Mutable: The elements of the list can be modified. We can add or remove items to the list after it has been created.

  • Ordered: The items in the lists are ordered. Each item has a unique index value. The new items will be added to the end of the list.

  • Heterogenous: The list can contain different kinds of elements i.e; they can contain elements of string, integer, boolean, or any type.

  • Duplicates: The list can contain duplicates i.e., lists can have two items with the same values.

46

LISTS SAMPLES IN PYTHON

media

47

LISTS INDEXING IN PYTHON

media

48

LISTS (+) INDEXING SAMPLE IN PYTHON

media

49

LISTS (-) INDEXING SAMPLE IN PYTHON

media

50

LISTS APPEND SAMPLE IN PYTHON

media

51

LISTS INSERT SAMPLE IN PYTHON

media

52

LISTS REMOVE SAMPLE IN PYTHON

media

53

LISTS REMOVE SAMPLE IN PYTHON

media

54

LISTS REMOVE SAMPLE IN PYTHON

media

55

LISTS REMOVE SAMPLE IN PYTHON

media

56

LISTS REMOVE SAMPLE IN PYTHON

media

57

LISTS EXTEND SAMPLE IN PYTHON

media

58

LISTS EXTEND SAMPLE IN PYTHON

media

59

LISTS MODIFY SAMPLE IN PYTHON

media

60

LISTS MODIFY ALL ITEM SAMPLES IN PYTHON

media

61

LISTS CONCATENATION SAMPLES IN PYTHON

media

62

LISTS DEEP COPYING SAMPLES IN PYTHON

media

63

LISTS USING COPY() SAMPLES IN PYTHON

media

64

LISTS SORT() SAMPLES IN PYTHON

media

65

LISTS REVERSE() SAMPLES IN PYTHON

media

66

LISTS MAX() & MIN() SAMPLES IN PYTHON

media

67

media

68

media

Q4 LESSON 3:

HANDS-ON ACTIVITY 4.3



Python Activity 10: Files and Nesting Looping Structures

Python Activity 11: Part A – Lists 

media

Show answer

Auto Play

Slide 1 / 68

SLIDE