Variables
Conditionals
Loops
Functions
Misc
100
Name the data type used to hold a decimal value and write a sample on the whiteboard
double or float sample: double x = 3.2;
100
What is the purpose of an IF statement
logic branch
100
What are loops used for in programming?
To repeat actions
100
Name 5 built-in functions in Processing
varies, includes draw() setup() mousePressed() keyPressed() rect() line() point() ellipse() etc...
100
What does the following expression return? !false
true
200
Name the data type used to hold an integer value and write a sample on the whiteboard
int myValue = 3;
200
Write a sample if statement checking for equality
if (3 == 3) { ... }
200
What are the 3 types of loops?
while do-while for
200
What is a parameter and what is an argument?
parameter is the variable declared in function parantheses, argument is the value passed to it
200
What does the following code print to the console? int counter = 0; while (counter < 3) { println("The counter is at " + counter); counter++ }
The counter is at 0 The counter is at 1 The counter is at 2
300
Name the data type used to hold a true/false value and give a "real-life" example
Boolean bool switchOn = true;
300
State the difference between: if(3 < 5) {...} else if ( 8 > 4) {...} vs if (3 < 5) {...} if (8 > 4) {...}
an else-if would only ever be evaluated if the first condition was false
300
What is the syntax of the for loop? Write it on the board.
for (initialization, condition, expression) { body }
300
What is the difference between a return type void and that of any other variable type?
void returns nothing, the others must return the type of variable expressed in the function definition
300
Write the code to draw a rectangle that has a width=10, height = 15, and a center point of x = 30, y = 25
rectMode(CENTER); rect(30, 25, 10, 15);
400
When should you use a variable? Give an example.
many answers
400
What's the output of: int b = 100; if (b > 99) { println("abc"); } println("xyz");
abc xyz
400
What is the correct type of loop to use? "A rabbit jumps continuously until you shut down the program." A. Repeat "x" times B. Repeat "infinity" times C. Repeat while "x" is true
B
400
In the following method, identify the parameters: "Write a function that allows the user to adjust how a rabbit jumps by setting the jump height, distance, and direction."
height, distance, direction
400
Identify the error in this code: void myFunc() { int sum = 0; for(int i = 0; i < 3; i++) { sum += i; } println("sum : " + sum); println("i: " + i); }
'i' does not exist in the scope of myFunc()
500
What is variable scope? Give two contrasting examples.
Global and local scope. Global is declared outside all functions. Local is a variable declared within a function.
500
What's the output of: int d = 100; int e = 88; if (d > 90) { println("abc"); } if (e < 95) { println""xyz"); } println("123");
abc xyz 123
500
What is the correct type of loop to use? "The game should restart until there are no more lives left." A. Repeat "x" times B. Repeat "infinity" times C. Repeat while "x" is true
C
500
On the whiteboard, write the function declaration (without body) for: "A function that returns the perimeter of a rectangle"
double perimeter(double width, double length) or all ints or all floats
500
Fix the errors in: function add(x, y) { return x + y; } x; x = add(2, 3);
int add(int x, int y) { return x + y; } int x; x = add(2, 3);
M
e
n
u