
CS 1 - Functions
Authored by Jon Kern
Computers
9th - 12th Grade
Used 4+ times

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why do we write functions?
Make our code easier to understand by giving a readable name to a group of instructions
Avoid writing repeated code
Make our code reusable
All of the above
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the following function printThreeTimes:
function printThreeTimes(word){
println(word);
println(word);
println(word); }
What is the parameter of the function?
printThreeTimes
function
println
word
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is printed by the following program?
function printNumbers(two, one, zero){
println(two);
println(one);
println(zero);
}
function start(){
var zero = 0;
var one = 1;
var two = 2;
printNumbers(zero, one, two);
}
2, 1, 0
0, 1, 2
zero, one, two
two, one, zero
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How many parameters go into the function sum, and how many return values come out of the function sum?
function sum(first, second, third){
var result = first + second + third;
println(first);
println(second);
println(third);
return result;
}
3 parameters go in, 1 return value comes out
3 parameters go in, 3 return values come out
1 parameter goes in, 4 return values come out
1 parameter goes in, 1 return value comes out
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
“It’s a bird! It’s a plane! No, it’s Superman!”We want to write a function isSuperman that takes in two parameters isBird and isPlane and returns true if it is in fact Superman, and false otherwise.If it’s not a bird and it’s not a plane, it must be Superman.Which of the following functions is the correct implementation of isSuperman?
function isSuperman(isBird, isPlane){ return isBird || isPlane; }
function isSuperman(isBird, isPlane){ return isBird && isPlane; }
function isSuperman(isBird, isPlane){ return !isBird || !isPlane; }
function isSuperman(isBird, isPlane){ return !isBird && !isPlane; }
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the following code:
function start(){ var length = 5; var width = 4; rectangleArea(length, width); } // This function prints out the area of // a triangle given its base and height function rectangleArea(base, height){ var area = base * height; println(area); }
What are the names of the parameters?
length and width
base and width
length and base
base and height
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
In the following code:
function drawCircle(radius, x, y, color) { var circle = new Circle(radius); circle.setPosition(x, y); circle.setColor(color); add(circle); }
What is the minimum number of parameters that must be given when calling the ‘drawCircle’ function?
1
2
3
4
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Операторы и функции языка Pascal
Quiz
•
1st - 10th Grade
10 questions
ก่อนเรียน หน่วยที่ 1 วิชาโปรแกรมกราฟิก
Quiz
•
10th Grade
10 questions
Introduction To Java: Hello World
Quiz
•
7th - 12th Grade
10 questions
KUIS EXCEL
Quiz
•
10th Grade
12 questions
Text File Pop Quiz
Quiz
•
11th Grade
12 questions
Java Quiz 1
Quiz
•
9th Grade
13 questions
Python Fundamentals and Programming
Quiz
•
11th - 12th Grade
10 questions
Javascript & Client side scripting
Quiz
•
10th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade