You are on page 1of 2

Activity Guide – Traversals Investigate

Work through levels 2, 3, and 4 in App Lab. Complete this worksheet as you progress through the levels.

Level 2: Run the app to see how it works. Think about the purpose of the app, the inputs, the outputs, and
how information might be processed to make the app function.

Read through the entire code then re-read the code for each function. If you have a partner, discuss the code
with them then answer the questions below.
average() (lines 32-38)
slow() (lines 40-48)
fast() (lines 50-58)
numberedListDisplay() (lines 60-66)

● What list does the average() function traverse? The average function traverses mile times.

● What happens within the loop? The mile times are added uo to a total then divided by the total
number of times to find an average.

● What list does the slow() function traverse? It traverses mile times.

● What happens within the loop? Finds the slowest times.

● What list does the fast() function traverse? Traverse the mile times.

● What happens within the loop? Finds the fastest times.

● What list does the numberedListDisplay() function traverse? This function traverses mile times.

● What happens within the loop? Displays the mile time it was and the time it took to run it.

Complete the modifications as directed then answer these questions.


● What list does your function traverse? It traverses mile times

● What happens within the loop? It adds together the total time of every element in the list

Level 3: Read through the code and run it. Data is printed to the console. Let's see where it came from.

Open the Data tab. Notice that bottom of the screen now shows a Data Library
and a Data Browser.
● What Data Table is available in the Data Browser?

Lists different breeds of cats.

● Click the table name to view the information in the table. What information is available?

Class list and shows on screen

● What can you change? What can't you change?

Can change info stored and can investigate some datasets

At the top of the table, click Back to data.


Investigate a few different datasets in the Data Library. Use the Preview button on a table to see the data
available.

● Name one table that you investigated and describe the data in the table.

I chose temperaments, and it listed many different types of temperaments.


Level 4: Run the program, watch the code run, and carefully read each individual part of the program.

● What are the names of the five lists in this program?


dogNames dogHeights dogImages filteredDogNames filteredDogImages
● On what lines of code are the lists created?
2-8
● On what lines of code are the lists filled?
32-43
● How are these lists filled?
For loops
● Open up the Data tab and click to view the Dogs table. What columns does this app use?
Name, heit, image
● Look at the filter() function. On what lines are the filtered lists reset to blank lists?
33,36,39
● What condition is being checked to determine if an element belongs in a filtered list?
If dog size is less than 16, the dog name is filtered.

Check Your Understanding

● Explain how you would filter the Dogs dataset using a traversal to have a filtered list of dogs who live
long lives.

● Traverse through the dataset: Using a loop, go through each dog in the dataset and evaluate if it
meets the criteria defined in step 1. Filter out the desired dogs: For each dog that meets the criteria,
add it to a new filtered list. This filtered list will contain only the dogs who live long lives.

You might also like