Presentation is loading. Please wait.

Presentation is loading. Please wait.

Looping and Random Numbers

Similar presentations


Presentation on theme: "Looping and Random Numbers"— Presentation transcript:

1 Looping and Random Numbers
Lesson 3-7 AP Computer Science Principles

2 Objectives Students will be able to:
Use a loop in a program to simplify the expression of repeated tasks. Identify appropriate situations in a program for using a loop. Use random values within a loop to repeat code that behaves differently each time it is executed.

3 Looping As we have developed as programmers, we have focused on the process of breaking down large tasks into smaller pieces and assigning each piece a function. When we break down a large task, often we will find that some portion of the task needs to be repeated many times. As programmers, we would simply call the same function many times. This might work if we need to call the same function five times, but if that function needs to be run 1,000,000 times, we’ll need a better solution.

4 Looping Today we’ll be exploring how a programming construct called a loop solves this problem by allowing us to repeat a set of commands many times. We’ll also practice looping through commands many times with random input, therefore giving us many instances of random output. Just as we saw last time, this will be both useful for testing our code and also for developing more variety in our drawings

5 Video

6 Stage 9 Complete Stage 9.

7 Journal Develop a rule for deciding when to use a loop within a program. Try to make connections to Top-Down Design in your response. Below your rule, write a couple sentences justifying your rule.


Download ppt "Looping and Random Numbers"

Similar presentations


Ads by Google