Why do we write functions?
I. Make our code easier to understand by giving a readable name to a group of instructions
II. Avoid writing repeated code
III. Make our code reusable
Quarter 3 Final Exam: Functions and Parameters
Quiz
•
Computers
•
9th - 12th Grade
•
Medium
Njemele Bush
Used 30+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why do we write functions?
I. Make our code easier to understand by giving a readable name to a group of instructions
II. Avoid writing repeated code
III. Make our code reusable
II and III
I only
I and II
I, II, and III
2.
MULTIPLE CHOICE QUESTION
45 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
word
println
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
What is the output of the following program?
function start(){
var x = 5;
sumTo(x);
println(x);
}
function sumTo(num){
var sum = 0;
for(var i = 0; i <= num; i++){
sum += i;
}
println(sum);
}
5
15
15
5
5
15
4.
MULTIPLE CHOICE QUESTION
45 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
2 mins • 1 pt
What is printed by the following program?
function product(x, y){
return x * y;
}
function difference(x, y){
return x - y;
}
function start(){
var x = 2;
var y = 5;
var value1 = product(x, y);
var value2 = difference(y, x);
var result = difference(value1, value2);
println(result);
}
-7
7
13
-13
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
True or false: Functions should have parameters.
True
False
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which statement allows us to return values from functions?
break
return
while
function
15 questions
JavaScript Quiz
Quiz
•
9th - 10th Grade
20 questions
Arrays in Java
Quiz
•
9th - 12th Grade
20 questions
Unit 1 - Introduction to Kotlin (L2)[ID]
Quiz
•
12th Grade
20 questions
TGT APCSA
Quiz
•
11th Grade
21 questions
CodeHS JavaScript
Quiz
•
8th - 12th Grade
20 questions
Quiz UTS Pemrograman Dasar C++
Quiz
•
10th Grade
15 questions
JavaScript and Graphics
Quiz
•
9th - 12th Grade
22 questions
IST CodeHS Unit 8 JavaScript Review
Quiz
•
9th - 12th Grade
15 questions
Character Analysis
Quiz
•
4th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
10 questions
American Flag
Quiz
•
1st - 2nd Grade
20 questions
Reading Comprehension
Quiz
•
5th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
18 questions
Full S.T.E.A.M. Ahead Summer Academy Pre-Test 24-25
Quiz
•
5th Grade
14 questions
Misplaced and Dangling Modifiers
Quiz
•
6th - 8th Grade
17 questions
Chapter 12 - Doing the Right Thing
Quiz
•
9th - 12th Grade
30 questions
Linear Inequalities
Quiz
•
9th - 12th Grade
20 questions
Types of Credit
Quiz
•
9th - 12th Grade
20 questions
Taxes
Quiz
•
9th - 12th Grade
17 questions
Parts of Speech
Quiz
•
7th - 12th Grade
20 questions
Chapter 3 - Making a Good Impression
Quiz
•
9th - 12th Grade
20 questions
Inequalities Graphing
Quiz
•
9th - 12th Grade
10 questions
Identifying equations
Quiz
•
KG - University