NEW
Font size
WorksheetsAP CSP Final
Total questions: 35
Worksheet time: 34mins
Consider the following code:
var a = 0
var b = 2
var c = 6
a = a+b
b=a+c
c=a+b
What are the values of a, b, and c after this code segment has been run?
a= 0 b=2 c=6
a=2 b=6 c=2
a=2 b=2 c=8
a= 2 b=8 c=10
You are writing a reply function for a text messaging app. You want to swap the sender and receiver so that the value currently in From ends up as the value in To and To ends up in From. Which code segments will correctly swap the values?
to = from
from = to
from = var temp
to = temp
from = to
var temp = from
from = to
to = from
var temp = from
from = to
to = temp
Consider the code segment:
var dist = 100
var radius = dist/20
penDown();
for(var i=0; i<4; i++){
moveForward(dist);
dot(radius);
turnRight(90);}
What image would this code produce?
A triangle with 3 medium dots
A square with 4 extremely large dots
A square with 4 medium dots
A triangle with 4 extremely large dots
What is the output to the console after the following code segment is run?
var x = 10;
increase();
x = x+3;
console.log(x);
function increase(){
var x =5}
5
8
10
13
Error. Cannot make a new variable x inside function increase()
The diagram below shows a circuit composed of three logic gates. Each gate takes two inputs and produces a single output. For which of the following input values will the circuit have an output of false?
A = true, B = false, C = false, D = false
A = true, B = true, C = false, D = false
A = false, B = false, C = true, D = true
A = false, B = false, C = false, D = true
