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

Understanding Code Functionality in App

This app uses two lists, one for nouns and one for adjectives. It displays a random band name by selecting a random adjective from the first list and a random noun from the second list and combining them into a string. The program includes index variables to track the list positions and calls an updateScreen function to refresh the display when the indexes change. Removing certain functions could prevent the screen from updating properly.

Uploaded by

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

Understanding Code Functionality in App

This app uses two lists, one for nouns and one for adjectives. It displays a random band name by selecting a random adjective from the first list and a random noun from the second list and combining them into a string. The program includes index variables to track the list positions and calls an updateScreen function to refresh the display when the indexes change. Removing certain functions could prevent the screen from updating properly.

Uploaded by

zetsu.3282
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1. Lines 1-2: Why does this program use two lists? What is each one storing?

The first line stores all the data on the pictures of tops that are in the app and it stores
the
information on the image and the second line is a list of all of the pictures of pants,
skirts, or
shorts that can be selected by pressing the bottom set of buttons.
Lines 4-5: Why does this program include the variables and ? What would topsIndex bottomsIndex

what would happen if these variables were removed from the program?
Line 4 and 5 are included because it tells the code to start at index 0, basically giving
the code
a place to start and display those images when the program is initially run. If those
variables
were removed, the code would not start with a picture of clothes displayed.
2. Lines 10-15: Write a short description of what this event handler does.
This event handler is the code that makes the top left button work. The code
basically says
that if the image shown in the picture is not the 0 index then it will go back one
index in the list
to display the previous picture.
3. Line 18: What is the conditional statement topsIndex < [Link] - 1 checking? What would
break if it was instead ?
topsIndex < [Link]

That conditional statement is checking if the index that is displayed is the end of the list and if it
is not
at the end of the list then code will run that moves to the next index value in the list. If there was
no -1 at
the end of the code the numbers would not be equal because the length of the list counts value
0 as 1
and the topsindex starts at 0 so the -1 makes the numbers equal if they are on the last value of
the
list.
4. Lines 38-43: Find all the places that the function is called. What changes about
updateScreen

the way the app runs if any of these calls were removed?
The update screen code is used to refresh the screen in a way so when the user inputs
something the screen will display what they changed and if one of these update screen
functions was removed then the screen would not change to a different piece of clothing.

Lines 1-2: Why are there two lists in this app instead of 1? This app needs one list for the
nouns and one for the adjectives. It might technically be possible to use a single list but it would
be very complicated.
Lines 4-5: Why is "Sideways Monkeys" always the first band name shown? These lines of
code set the two different indexes to 0 to start and "Sideways" and "Monkeys" are the first
values
in the adjective and noun lists.
Line 10: What would break if this line read randomNumber(0,[Link]) instead of
randomNumber(0,[Link]-1)? Sometimes the app would pick a number that is equal
to [Link] which is off the edge of the list. This is a good one to demonstrate to the class.
Lines 17-20: Write a short description of what each line in this function is doing. Line 17
takes the adjective at the current adjective index. Line 18 grabs the noun at the current noun
index. Line 19 create a string that combines these two words and line 20 puts them on the
screen

Line 6: What does .join() do? Why is it necessary for this app to run? .join() takes a list
and turns it into a string, connecting the different elements using whatever connector string it's
given. This is the only way to take the list and turn it into something that can be assigned to an
element.
Line 7: This line of code references an "options" property of a dropdown. Go look at what
that property does in Design Mode. Then write a short description of what this line of code
does. This line of code is assigning a list to a dropdown
Lines 18-19: This line of code references an "index" property of a dropdown. Go look at
what that property does in Design Mode. Then describe how these lines of code work
together to remove a user from the list of partners? The index property keeps track of which
option in the dropdown is currently shown. These lines of code let the user select the current
user
and then removes it from the list of people. Then the screen is updated with the user removed.
Line 24: Why does this conditional read [Link] >= 2? What would break if it
read [Link] >= 1 instead? This is checking that there are at least two people in
the list to make a pair. With the change suggested you might try to make a pair when there's
only
one person in the list, causing an error when trying to find a second partner.
Line 26 - 27: What would happen if you switched the order of these two lines of code?
Switching these lines of code would mean that the person was removed from the list before their
The name was picked. This means that a different person would actually be removed from the
list
then displayed on the screen. This is a good one to actually try out in class.

Open the data tab. What does it do? Shows all the data in the app
How does it work? Lets you look and read all the data
What information is available? cats
What can you change? What can't you change? You can change and make new table names
you cant change what is in the tables

Investigate a few different datasets.

Describe what will happen when the program is run and the user clicks on the 8-ball. Try to
visualize how the code will run when the user clicks on the 8-ball.
Clicking on the 8-ball in a computer program typically triggers an event or action defined by the
program's code, such as starting a simulation or displaying information within an Interactive
Labs environment. The specific outcome is determined by the instructions coded into the
program based on the user's interactions.

You might also like