Unit 5
Lesson 11 part 2 Traversals Practice
To do: January 24
Take out your midterms - be ready to turn in.
The two programs below are both intended to display the total number of hours from a list of durations in minutes.
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
}
totalHours ← mins / 60
DISPLAY(totalHours)
totalHours ← 0
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
totalHours ← mins / 60
}
DISPLAY(totalHours)
A
B
To do: January 24
The two programs below are both intended to display the total number of hours from a list of durations in minutes.
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
}
totalHours ← mins / 60
DISPLAY(totalHours)
Which program(s) works? Explain why.
A
B
totalHours ← 0
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
totalHours ← mins / 60
}
DISPLAY(totalHours)
To do: January 24
The two programs below are both intended to display the total number of hours from a list of durations in minutes.
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
}
totalHours ← mins / 60
DISPLAY(totalHours)
Both programs work! Which one unnecessarily repeats arithmetic operations?
A
B
totalHours ← 0
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
totalHours ← mins / 60
}
DISPLAY(totalHours)
To do: January 24
The two programs below are both intended to display the total number of hours from a list of durations in minutes.
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
}
totalHours ← mins / 60
DISPLAY(totalHours)
Both programs work! Which one unnecessarily repeats arithmetic operations? Program B
A
B
totalHours ← 0
mins ← 0
durations ← [32, 56, 28, 27]
FOR EACH duration IN durations
{
mins ← mins + duration
totalHours ← mins / 60
}
DISPLAY(totalHours)
Go over homework
Friday - Test on lists and traversing lists in JavaScript (open response) and pseudocode (MC)
Grades.ly in Lesson 11
Go to Code.org U5L11 bubble 7.
Grades.ly in Lesson 11
1. What is the name of the list you will need to traverse?
2. How do you find the average of a list of numbers?
3. Type the for loop header you will need to use to traverse the list:
Grades.ly in Lesson 11
Complete bubble 7 and then complete goFormative.
When you're done, go to bubble 8 and complete code.
U5L12 Traversals Make: Random Forecaster App
Homework
Friday - Test on lists and traversing lists in JavaScript (open response) and pseudocode (MC)