-
This lesson is called For Loop Fun. In this
lesson, we'll use a number line to play a dice game.
-
Each player will roll three times
to assign a starting value,
-
a stopping value, and our interval.
-
During each turn, we circle
our starting value, and every value that is
-
the same number of steps forward as our interval
value.
-
We stop circling when we get to our stopping value.
-
The person with the highest
score wins!
-
For loops can come in handy in a lot of places.
-
If you were a
meteorologist, you would use for loops all the time.
-
Hi, I'm Becky. I work at Able Driller
Renewables as a wind meteorologist.
-
I forecast wind speeds for the Columbia River Gorge area, where the company owns wind farms.
-
We're trying to understand how much wind is going to be there,
-
so that we know how much power is going to be outputted.
-
We give that information to real time energy traders. They buy and sell power,
-
based on how much power we tell
them is going to be there, in order to make sure
-
the power grid is balanced, your lights stay on,
-
and that we maximize energy we get out of our wind farms.
-
We're at the national control center for Eber Troller Renewables here in Portland,
-
and this is where we have information coming in from all our farms across the country.
-
Even the highest power computers
today can't simulate the atmosphere everywhere.
-
In computer forecasting models, we have what
we call a grid. Each grid point is a latitude,
-
and a longitude. We have to calculate the physics,
-
and try to figure out wind speeds, temperature, pressure, that sort of thing.
-
Since these are fairly big grids and we're doing this in a lot of points,
-
we're looping over these
things millions and millions of times.
-
Everything I do, I'll use for loops. Here for example
is a for loop right there.
-
When you're forecasting wind, there's so many different parameters that go into it,
-
that go into it it would be impossible for a human to sit down and do all those calculations.
-
There's so many different aspects to what's going to be affecting the wind
-
that we need a computer model in order to forecast it.