Deck 19: Programming Functions

ملء الشاشة (f)
exit full mode
سؤال
Functions allow for code to be reused because parts of the solutions are hidden .
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Variables in the parameter list of a JavaScript function are declared automatically .
سؤال
The name of a function identifies it and must be used when the function is called .
سؤال
Function names cannot contain numbers and must not be more than eight characters long .
سؤال
The return value for a JavaScript function must be a variable .
سؤال
Local variables cannot be accessed outside the functions in which they are declared .
سؤال
When calling a function, it does not matter which order you list the arguments .
سؤال
A variable cannot be used as part of a calculation to assign a value to itself . For example, this JavaScript statement would cause an error, assuming myNum is a numeric variable that has been previously declared and initialized:myNum = myNum*3 + 75/myNum;
سؤال
A function definition is the same as a function call .
سؤال
If a function definition contains two parameters, two arguments must be included in the function call .
سؤال
JavaScript functions can be placed in the <head> section of a web page .
سؤال
A JavaScript function include at least one parameter .
سؤال
A computer cannot generate a truly random number .
سؤال
When two variables have the same name, but one is global and one is local, the JavaScript program will not run .
سؤال
The arguments in a function call pass values to the parameters, matched in order from left to right .
سؤال
Programmers rarely use code written by others .
سؤال
Variables declared within a function

A) cannot be changed in that function
B) can only be used inside the function
C) can be used anywhere in the program
D) can be used outside the function but cannot be changed outside the function
سؤال
Output directly onto a web page from JavaScript is done using the ________ built-in function .

A) document . display()
B) print()
C) writeln()
D) document . write()
سؤال
A variable declared in a function is a(n)

A) independent variable
B) named constant
C) local variable
D) global variable
سؤال
When defining a function that sends a value back to the part of the program that calls it, how do you specify the result?

A) by rewriting it
B) by using the return statement
C) by calling it
D) by designating it as an argument
سؤال
The inputs to a function are called

A) parameters
B) arguments
C) identifiers
D) values
سؤال
What, if anything, is wrong with the following JavaScript code?
<script>document . write("<img src = 'puppy . JPG'/>");</script>

A) You cannot use document . write() to display an image; it can only display text .
B) The outer double quotes are not needed with the document . write() function .
C) You cannot use the document . write() function with JavaScript; it must be used with a form .
D) Nothing is wrong with this code .
سؤال
The values returned by the Math . random()function are between

A) 0 (exclusive) and 1 (exclusive)
B) 0 (inclusive) and 1 (inclusive)
C) 0 (exclusive) and 1 (inclusive)
D) 0 (inclusive) and 1 (exclusive)
سؤال
The numbers generated by the Math . random()function

A) will never be repeated
B) are random because a computer is deterministic
C) must be multiplied by -1 to change them to positive
D) are pseudo-random
سؤال
Given the following JavaScript function, which of the following is NOT a possible result?
Function tossIt() {
Return Math . random();
}

A) 0 . 5
B) 0 . 8923871
C) 0
D) 1
سؤال
If you wanted the following function to return only the two values of 0 and 1, how would you re-write line 2?
1 ) function tossIt() {
2 ) return Math . random();
3 ) }

A) return Math . round();
B) return Math . round(Math . random());
C) return Math . round(random());
D) This cannot be done .
سؤال
After running the following JavaScript, what is the value of the variable month?
Var newDay = new Date();
Month = newDay . setMonth(4);

A) April
B) June
C) May
D) cannot tell because it depends on what the current date is
سؤال
Select all that apply . What does the following command do?
Ctx . quadraticCurveTo(20,20,20,50);

A) The curve will end at the point where x = 20 and y = 50
B) The curve will start at the point where x = 20 and y = 20
C) It specifies a curved line .
D) The curve will start at the point where x = 20 and y = 50
سؤال
Select all that apply . Which of the following are alternate terms for the word 'function'?

A) procedure
B) subroutine
C) method
D) process
سؤال
Select all that apply . Which of the following are required parts of a function?

A) the local variables
B) the definition
C) the name
D) the parameters
سؤال
Select all that apply . In JavaScript the result of a function call can be displayed to the user

A) by using an alert()
B) by using the document . write() method
C) by using an absolute reference
D) by using the document . display() method
سؤال
A function ________ is the algorithm written in a programming language that computes function's result .
سؤال
A(n) ________ is a programming structure with a name, an optional parameter list, and a definition that encapsulates an algorithm .
سؤال
Variables declared inside a function are ________ in scope .
سؤال
When you write code to ask the computer to run or execute the statements in a function, this is referred to as ________ the function .
سؤال
Functions that are written so they can be reused in other programs are considered ________ .
سؤال
A function is declared by writing its function ________ .
سؤال
Date() creates a JavaScript ________ which represents a date and a time .
سؤال
Joining several components together, as in:
'<tr style="background-color:00ccff ">' + '<td>-10</td><td>' +
convertC2F(-10) + '</td></tr>'
is done using the ________ operator .
سؤال
The HTML ________ tag provides an area where JavaScript can draw lines and figures .
سؤال
Other names for a function are ________ or method . Subroutine is an antiquated term for the same thing .
سؤال
When a function is called, you write the function's name and include any necessary arguments (that is, input values) inside ________ .
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 19: Programming Functions
1
Functions allow for code to be reused because parts of the solutions are hidden .
False
2
Variables in the parameter list of a JavaScript function are declared automatically .
True
3
The name of a function identifies it and must be used when the function is called .
True
4
Function names cannot contain numbers and must not be more than eight characters long .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
5
The return value for a JavaScript function must be a variable .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
6
Local variables cannot be accessed outside the functions in which they are declared .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
7
When calling a function, it does not matter which order you list the arguments .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
8
A variable cannot be used as part of a calculation to assign a value to itself . For example, this JavaScript statement would cause an error, assuming myNum is a numeric variable that has been previously declared and initialized:myNum = myNum*3 + 75/myNum;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
9
A function definition is the same as a function call .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
10
If a function definition contains two parameters, two arguments must be included in the function call .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
11
JavaScript functions can be placed in the <head> section of a web page .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
12
A JavaScript function include at least one parameter .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
13
A computer cannot generate a truly random number .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
14
When two variables have the same name, but one is global and one is local, the JavaScript program will not run .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
15
The arguments in a function call pass values to the parameters, matched in order from left to right .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
16
Programmers rarely use code written by others .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
17
Variables declared within a function

A) cannot be changed in that function
B) can only be used inside the function
C) can be used anywhere in the program
D) can be used outside the function but cannot be changed outside the function
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
18
Output directly onto a web page from JavaScript is done using the ________ built-in function .

A) document . display()
B) print()
C) writeln()
D) document . write()
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
19
A variable declared in a function is a(n)

A) independent variable
B) named constant
C) local variable
D) global variable
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
20
When defining a function that sends a value back to the part of the program that calls it, how do you specify the result?

A) by rewriting it
B) by using the return statement
C) by calling it
D) by designating it as an argument
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
21
The inputs to a function are called

A) parameters
B) arguments
C) identifiers
D) values
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
22
What, if anything, is wrong with the following JavaScript code?
<script>document . write("<img src = 'puppy . JPG'/>");</script>

A) You cannot use document . write() to display an image; it can only display text .
B) The outer double quotes are not needed with the document . write() function .
C) You cannot use the document . write() function with JavaScript; it must be used with a form .
D) Nothing is wrong with this code .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
23
The values returned by the Math . random()function are between

A) 0 (exclusive) and 1 (exclusive)
B) 0 (inclusive) and 1 (inclusive)
C) 0 (exclusive) and 1 (inclusive)
D) 0 (inclusive) and 1 (exclusive)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
24
The numbers generated by the Math . random()function

A) will never be repeated
B) are random because a computer is deterministic
C) must be multiplied by -1 to change them to positive
D) are pseudo-random
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
25
Given the following JavaScript function, which of the following is NOT a possible result?
Function tossIt() {
Return Math . random();
}

A) 0 . 5
B) 0 . 8923871
C) 0
D) 1
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
26
If you wanted the following function to return only the two values of 0 and 1, how would you re-write line 2?
1 ) function tossIt() {
2 ) return Math . random();
3 ) }

A) return Math . round();
B) return Math . round(Math . random());
C) return Math . round(random());
D) This cannot be done .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
27
After running the following JavaScript, what is the value of the variable month?
Var newDay = new Date();
Month = newDay . setMonth(4);

A) April
B) June
C) May
D) cannot tell because it depends on what the current date is
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
28
Select all that apply . What does the following command do?
Ctx . quadraticCurveTo(20,20,20,50);

A) The curve will end at the point where x = 20 and y = 50
B) The curve will start at the point where x = 20 and y = 20
C) It specifies a curved line .
D) The curve will start at the point where x = 20 and y = 50
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
29
Select all that apply . Which of the following are alternate terms for the word 'function'?

A) procedure
B) subroutine
C) method
D) process
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
30
Select all that apply . Which of the following are required parts of a function?

A) the local variables
B) the definition
C) the name
D) the parameters
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
31
Select all that apply . In JavaScript the result of a function call can be displayed to the user

A) by using an alert()
B) by using the document . write() method
C) by using an absolute reference
D) by using the document . display() method
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
32
A function ________ is the algorithm written in a programming language that computes function's result .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
33
A(n) ________ is a programming structure with a name, an optional parameter list, and a definition that encapsulates an algorithm .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
34
Variables declared inside a function are ________ in scope .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
35
When you write code to ask the computer to run or execute the statements in a function, this is referred to as ________ the function .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
36
Functions that are written so they can be reused in other programs are considered ________ .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
37
A function is declared by writing its function ________ .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
38
Date() creates a JavaScript ________ which represents a date and a time .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
39
Joining several components together, as in:
'<tr style="background-color:00ccff ">' + '<td>-10</td><td>' +
convertC2F(-10) + '</td></tr>'
is done using the ________ operator .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
40
The HTML ________ tag provides an area where JavaScript can draw lines and figures .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
41
Other names for a function are ________ or method . Subroutine is an antiquated term for the same thing .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
42
When a function is called, you write the function's name and include any necessary arguments (that is, input values) inside ________ .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.