Code.org

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What will the following program display in the console? for(var i = 0; i < 4; i++){ console.log(i); }

0 1 2 3

What will the following program display in the console? var sum = 0; for(var i = 0; i < 5; i++){ sum = sum + i; } console.log(sum);

10

What will be displayed in the console when this program runs? var numList = [10,20,30]; console.log(numList[numList.length-1]);

30

What will be displayed when this program finishes running? var numbersList = [20, 10, 5] appendItem(numbersList, 50) appendItem(numbersList,100) removeItem(numbersList,1) insertItem(numbersList, 0, 30) console.log(numbersList.length)

5

A job placement agency helps match job seekers with potential employers. The agency would like to design a simulation in order to help predict the likely job placement outcomes for job seekers based on historical trends and patterns. What would likely be a benefit of the simulation?

The computer simulation could be used to test hypotheses about patterns in the job placement process that are costly or time consuming to observe in reality.

If a school is developing a program to keep track of information about students and their class schedules. How could a data abstraction be most helpful?

The program should include individual variables to store the names of each student rather than a single list of students.

var words = ["apple","bug","car","dream","ear", "food"] var filteredWords = []; for(var i = 0; i < words.length; i++){ var word = words[i]; if (word.length < 4){ appendItem(filteredWords,word) } } console.log(filteredWords); If the program above is run, what will be displayed in the console?

[bug, car, ear]

ageList and gradeList contain information about students in a classroom. A programmer has already written the following code with that information. var ages = [16,17,18, 17]; var names = ["Beni", "Analise", "Ricardo", "Tanya"]; var filteredNames = []; var age; What program will result in filteredNames only containing the names of students who are 17 or older?

for(var i = 0; i < ages.length; i++){ age=ages [i]; if (age >= 17){ appendItem(filteredNames, names[i])

var list = [10, 5, 15]; for(var i = 0; <INSERT CODE>; i++){ console.log(list[i]); } Read the code above. What code would result in ONLY all the items in list being printed to the console if placed where the program reads <INSERT CODE> and the program is run?

i < list.length

A program is designed to determine the minimum value in a list of positive numbers called numList. The following program was written var minimum = <MISSING CODE> for(var i = 0; i < numList.length; i++){ if (numList[i] < minimum){ minimum = numList[i]; } } console.log("The minimum is" + minimum); What could be used to replace <MISSING CODE> so that the program works as intended for every possible list of positive numbers?

numList[0]

A restaurant knows from historical data that 60 out of 100 of its customers purchase a full meal while 40 out of 100 only order a side dish. The program below is intended to simulate the orders of 1000 customers. fullMeal ← 0 sideDish ← 0 REPEAT 1000 TIMES { IF (<MISSING CODE>) { fullMeal ← fullMeal + 1 } ELSE { sideDish ← sideDish + 1 } } DISPLAY (fullMeal) DISPLAY ("full meals were ordered,") DISPLAY (sideDish) DISPLAY ("side dishes were ordered.") What can be used to replace <MISSING CODE> so that the simulation works as intended?

random(1,100) <= 60

What program will move the robot to the gray square following the path shown on the grid?

repeat 2 times, repeat 3 times, move forward, turn left.

A 2-sided coin has an equal likelihood of landing on each side. One side is called "heads" and the other is called "tails". The program below simulates randomly flipping that coin many times. var heads = 0; var tails = 0; var rolls = 100; for(var i = 0; i < rolls; i++){ if(randomNumber(0,1) == 0){ heads++ } else { tails++ } } Several combinations can happen as a result of the above program but what will not/is NOT a possible combination of values of the variables in this program when it finishes running?

tails has a value of 20 and head has a value of 20 (total of any number more or less than 100)

What will be displayed in the console when the following program runs? var count = 0 while (count != 5){ console.log(count); count = count + 2; }

the program will result in an infinite loop

wordList is a list of words that currently contains the values ["tree", "rock", "air"] What line of code will result in the list containing the values ["air", "rock", "air"]

wordList[0] = wordList[2]


संबंधित स्टडी सेट्स

Chapter 2 (North America--US and Canada)

View Set

Chapter 2: Highway Transportation System

View Set

CPA Regulation: Ethics and Responsibilities Part 2

View Set