0% found this document useful (0 votes)
57 views3 pages

Activity Guide - Traversals Make

Uploaded by

1180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views3 pages

Activity Guide - Traversals Make

Uploaded by

1180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit 5 Lesson 12

Name(s)_______________________________________________ Period ______ Date ___________________

Activity Guide - Traversals Make


Step 1 - Try the app
● Click on "Get Forecast"
● Click the button several times to see how the
display changes "fore
"cit
Discuss with a Partner
● What information is needed to create this app? "high "ic
● What list filtering patterns might be used?
"low
Step 2 - Plan
"con
Lists: This app uses the Daily Weather table. Open the data tab and click on the table. Which columns do you think
you will use in this app? The columns will be stored as lists in your program. There are 6 columns used in this app.
Column Name of List What is stored

City cityList A list of cities

Forecast Number forecastNumberList The number of days from today (for example: 1 = tomorrow)

conditionList

Filtered Lists: What lists will be filtered? What list will be used to filter these lists? Remember, we want to only display
the forecast for tomorrow. There are 5 filtered lists and one list which is traversed to filter the other lists.
Original List Filtered List Filtered by

cityList filteredCityList

conditionList filteredConditionList

Computer Science Principles 1


Unit 5 Lesson 12
Traversal: Review the List Filter Pattern: Filtering Multiple Lists. Consider how you will use this in your app.
All the lists must be the same length for
this pattern - ideally they are columns
pulled from a table

How does it work?


● Create a variable for each list
● Create blank lists to store the
filtered lists
● In a function, first reset all
filtered lists to blank lists. Every
time the function is called, the
filtered lists will reset.
● Use a for loop to access each
item in the list that contains the
element you are filtering by
● If the element is found, append
to each filtered list the element
at the index in the original lists
where the element was found

Output: Think about a function that updates the screen. This app displays a random city's forecast. How will the
random city be selected? How will that information be used to display data from the filtered lists?

How will the random city be selected:

How will that information be used to display data from the filtered lists:

Computer Science Principles 2


Unit 5 Lesson 12
Step 3 - Write Your Code
● Write the code for the app, using your plan above and the comments provided in Code Studio to help
● Step You Can Follow
○ Create all the lists from your tables above.
○ Give your variables a starting value using the assignment operator (=). For lists that are created from
columns in the table, use getColumn() to populate the lists.
○ Create a function to filter the lists. Refer to the List Filter Pattern.
○ Create a function that updates the screen.
○ Update the output elements on the screen inside of the function that updates the screen.
○ Create an onEvent() for the user input and call the function that updates the screen.
○ Use your debugging skills to identify unexpected behavior and fix your program
○ Comment your code as you go, explaining what each event handler and function does
● Extension Ideas
○ Create a button that deletes unwanted items from the list.
○ Change the list scrolling so that it wraps from the end of the list back to the beginning.

Step 4 - Submit
Before your submit check the rubric below to make sure your program
Category Extensive Evidence Convincing Evidence Limited Evidence No Evidence

Input onEvents are created onEvents are created onEvents are created onEvents are not
for all the required for most of the inputs. for some of the inputs. created for any
inputs. inputs.

Storage: Variables and lists are Variables and lists are Some information is There are no
Variables and created and created and stored in variables and variables or lists
Lists appropriately used for appropriately used for lists and appropriately which store the
all pieces of information most pieces of updated throughout the necessary
used in the app. information used in the app. information for the
app. app to work correctly.

Processing: The program correctly The program correctly The program correctly The program does
Lists processes the list for all processes the list for processes the list for not include or does
user interface most user interface some of the user not process a list.
elements. elements. interface elements.

Code: A function is used A function is used A function is used There is no function


Functions which correctly updates which correctly which updates some of which updates the
all output elements. updates most of the the output elements or screen.
The function is called in output elements. The the function is only
the appropriate function is called in the called in some of the
onEvents. appropriate onEvents. appropriate onEvents.

Output The screen correctly The screen displays The screen displays The screen does not
displays a random city's most of a random city's some of a random correctly display any
forecast. forecast. city's forecast. of a random city's
forecast..

Code runs No errors are present in One or two errors are Three or four errors are More than four errors
without errors. the required code. present in the required present in the required are present in the
code. code. required code.

Coding Comments are used to Comments are used to Comments are used to Comments are not
Comments correctly explain the explain the purpose explain the purpose present.
purpose and function of and function of most and function of some
all onEvents and onEvents and onEvents and
functions. functions. functions.

Computer Science Principles 3

You might also like