What are the two kinds of loops we have spoken about in class?
For loops and while loops
Fill in the blanks. Maps store _____:_____ pairs.
key and value
If I were to print set.size in the console, what would appear, if I have added 5, 11, 13, 11, 7, 9, and 32 to the set?
6
What index is the number 3 in the array? x = [2, 4, 3, 5, 9, 11]
2
True or False: An array of arrays is immutable.
False
Which variable in the code below is the "iterative variable?"
var x = 5
for(var z = 0; z < x; z = z + 1){
var g = await readLineAsync("Gimme a #:")
var y = 10
}
z
What appears in the console from the code below?
var my_first_map = {Anna: "Volleyball", Darcey: "Soccer",Joey: "Swimming"}
print(my_first_map["Darcey"])
Soccer
True or False: If I add 3, 9, and 17 to a set, I can access the number 9 by printing set[1]
Write the code to remove the last number in an array called peanuts.
peanuts.pop()
arr = [[1, 2], [4, 9], [7, 8, 9], [2, 1]]
Write the code to access the second 9 in the array.
arr[2][2]
True or False: A for loop can be turned into a while loop, but a while loop cannot always be turned into a for loop.
True
What appears in the console from the code below?
var my_first_map = {Anna: "Volleyball", Darcey: "Soccer",Joey: "Swimming"}
print(my_first_map[0])
Error/undefined
Write the code to put a new value, "PC", into a set called computers.
computers.add("PC")
Write the code to put a value, "PC", into an array called computers.
computers.append["PC"]
What do I print to see what grade Joey is getting in his 3rd class?
var grades = {Anna: [97, 95, 82], Darcey: [88, 92, 75, 81], Joey: [85, 91, 99, 80]}
How many times will the following loop print(1)?
for (var i = 1; i < 8, i = i + 3){
print(1)
}
3
for(var key in pro){
print(pro[key])
}
Write how to make an empty set called ss.
The array below is super long. How would you figure out where the number 10 is in the array?
var arr = [3, 9, ..........., 67, 10, 32, ........, 11]
arr.indexOf(10)
Write an example of a map where the keys are letters in the alphabet and the values are words that start with that letter. Have 2 keys and 3 words for each.
{a:[apple, aardvark, antelope], b:[banana, brick, brownie]}
Write the while loop that is the same as the for loop below.
for(var i = 0; i < 11; i++){
}
var i = 0
while(i<11){
i++
}
Write the 3 characteristics of a map? (mixedness, orderliness, and uniqueness) Be specific.
Keys act as positional values, keys are to maps as indices are to arrays.
All keys will become strings, but values can be of any variable type.
Joes_classes.intersect(Toms_classes)
Toms_classes.intersect(Joes_classes)
Write the code to add the number 3 to an array called "z" 5 times.
var z = []
for(var i = 0; i<5; i++){
z.append(3)
}
Josie is working on a project to log the pressure, temperature, and humidity in her room what data structure/structures should she use to store that data in a single variable.
an array of arrays