Search Header Logo
Iteration

Iteration

Assessment

Presentation

Computers

7th Grade

Practice Problem

Medium

Created by

Andy Wilkinson

Used 2+ times

FREE Resource

9 Slides • 4 Questions

1

Iteration

By Mr Wilkinson

2

Learning Objectives

Understand the use of following constructs in programming - Iteration

Lesson Components

  • To understand what is meant by iteration.

  • To write a program that draws basic shapes using counter-controlled iteration (FOR Loop).

  • To adapt a program for the number of times it needs to repeat for a given purpose.

3

Iteration

Iteration is a process of repeating steps.
It's the final programming construct along sequence and selection.
In programming we use something called "Loops".

​A loop is a programming construct that repeats a block of code until a specific condition is met.

media

4

Iteration

"For Loop"

A for loop repeats code for each item in a sequence or a set number of times. Use it when you know how many repetitions you need.

media

​What will the outcome be if the user enter the number 10?

5

Iteration

media

​It keeps repeating what is in the for loop under the it hit's the number we enter, in our case "10"

media

6

Iteration

"While Loops"

A while loop repeats code as long as a condition stays true. Use it when you don't know how many repetitions you need.

​What's happening here?

media

7

Multiple Choice

Which type of loop would you use for this scenario:

Print "Happy Birthday" exactly 5 times:

1

For

2

While

8

Multiple Choice

Which type of loop would you use for this scenario:

Keep asking for a password until the user enters "python123"

1

For

2

While

9

Multiple Choice

Which type of loop would you use for this scenario:

Display each name in a list of 10 students

1

For

2

While

10

Multiple Choice

Question image

What's going to be the output here?

1

2

2

2

3

4

5

6

3

2

4

4

2

4

6

11

media

​New Information

​The turtle module allows you to draw shapes.

  • Which shape do you think is code will draw?

  • How could we use less blocks of code to draw the same shape.

12

​New Information

We could have used a "For Loop"

media

13

media

Today's worksheet

Iteration

By Mr Wilkinson

Show answer

Auto Play

Slide 1 / 13

SLIDE