1 of 11

Unit 5

Lesson 11 part 2 Traversals Practice

2 of 11

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

3 of 11

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)

4 of 11

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)

5 of 11

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)

6 of 11

Go over homework

  • Complete Code.org U5L11 bubbles 1-6.
  • Complete goFormative U5L11 Traversals Practice
  • Complete your midterm exam corrections in your IN or separate sheet of paper - for each problem missed
    • Write a summary of the question
    • Write out the correct answer (in words)
    • Explain your misunderstanding

Friday - Test on lists and traversing lists in JavaScript (open response) and pseudocode (MC)

7 of 11

Grades.ly in Lesson 11

Go to Code.org U5L11 bubble 7.

  • Read and run the code to understand how it works
  • Add code to the program to calculate the average of the grades when the user clicks the button

8 of 11

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:

9 of 11

Grades.ly in Lesson 11

Complete bubble 7 and then complete goFormative.

When you're done, go to bubble 8 and complete code.

10 of 11

U5L12 Traversals Make: Random Forecaster App

  • Go to Code.org U5L12 bubble 1.
  • Run the app to see how it works.

11 of 11

Homework

  • Complete goFormative U5L11 bubble 8: Grades.ly app
  • Khan Academy articles and exercises - graded on accuracy
    • Iterating over lists with loops

Friday - Test on lists and traversing lists in JavaScript (open response) and pseudocode (MC)