Deck 5: Functions and Modules
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/69
العب
ملء الشاشة (f)
Deck 5: Functions and Modules
1
The first line in the function definition is known as the function _____.
A) header
B) block
C) return
D) parameter
A) header
B) block
C) return
D) parameter
A
2
A variable's _____ is the part of a program in which the variable may be accessed.
A) global
B) argument
C) scope
D) local
A) global
B) argument
C) scope
D) local
C
3
It is recommended that programmers should avoid using _____ variables in a program when possible.
A) local
B) global
C) string global
D) keyword
A) local
B) global
C) string global
D) keyword
B
4
Python comes with _____ functions that have been already prewritten for the programmer.
A) standard
B) library
C) custom
D) built-in
A) standard
B) library
C) custom
D) built-in
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following statements causes the interpreter to load the contents of the random module into memory?
A) load random
B) import random
C) upload random
D) download random
A) load random
B) import random
C) upload random
D) download random
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
6
A(n) _____ variable is accessible to all the functions in a program file.
A) keyword
B) local
C) global
D) string
A) keyword
B) local
C) global
D) string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
7
A set of statements that belong together as a group and contribute to the function definition is known as a(n) _____.
A) header
B) block
C) return
D) parameter
A) header
B) block
C) return
D) parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
8
When a function is called by its name, then it is _____.
A) executed
B) located
C) defined
D) exported
A) executed
B) located
C) defined
D) exported
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
9
What is the result of the following statement?
X = random.randint(5, 15) * 2
A) A random integer from 5 to 15, multiplied by 2, assigned to the variable x
B) A random integer from 5 to 15 assigned to the variable x
C) A random integer from 5 to 15, selected in 2 steps, assigned to the variable x
D) A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
X = random.randint(5, 15) * 2
A) A random integer from 5 to 15, multiplied by 2, assigned to the variable x
B) A random integer from 5 to 15 assigned to the variable x
C) A random integer from 5 to 15, selected in 2 steps, assigned to the variable x
D) A random integer from 5 to 15, raised to the power of 2, assigned to the variable x
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
10
A(n) _____ variable is created inside a function.
A) global
B) constant
C) defined
D) local
A) global
B) constant
C) defined
D) local
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
11
A(n) _____ is any piece of data that is passed into a function when the function is called.
A) global
B) argument
C) scope
D) parameter
A) global
B) argument
C) scope
D) parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
12
The Python library functions that are built into the Python _____ can be used by simply calling the function.
A) code
B) compiler
C) linker
D) interpreter
A) code
B) compiler
C) linker
D) interpreter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
13
The _____ design technique can be used to break down an algorithm into functions.
A) subtask
B) block
C) top-down
D) simplification
A) subtask
B) block
C) top-down
D) simplification
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
14
What is a group of statements that exists within a program for the purpose of performing a specific task?
A) function
B) subtask
C) procedure
D) subprogram
A) function
B) subtask
C) procedure
D) subprogram
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following will assign a random number in the range of 1 through 50 to the variable number?
A) random(1,50) = number
B) number = random.randint(1, 50)
C) randint(1, 50) = number
D) number = random(range(1, 50))
A) random(1,50) = number
B) number = random.randint(1, 50)
C) randint(1, 50) = number
D) number = random(range(1, 50))
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
16
The _____ argument specifies which parameter the argument should be passed into.
A) keyword
B) local
C) global
D) string
A) keyword
B) local
C) global
D) string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
17
A(n) _____ chart is also known as a structured chart.
A) flow
B) data
C) hierarchy
D) organizational
A) flow
B) data
C) hierarchy
D) organizational
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
18
A(n) _____ constant is a global name that references a value that cannot be changed.
A) keyword
B) local
C) global
D) string
A) keyword
B) local
C) global
D) string
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
19
The _____ of a local variable is the function in which the variable is created.
A) global
B) defined
C) local
D) scope
A) global
B) defined
C) local
D) scope
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
20
A(n) _____ is a variable that receives an argument that is passed into a function.
A) global
B) argument
C) scope
D) parameter
A) global
B) argument
C) scope
D) parameter
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
21
Given the following function definition, what would the statement print magic(5) display?
Def magic(num):
Return num + 2 * 10
A) 70
B) 25
C) Statement will cause a syntax error.
D) Statement will cause a run-time error.
Def magic(num):
Return num + 2 * 10
A) 70
B) 25
C) Statement will cause a syntax error.
D) Statement will cause a run-time error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
22
One of the reasons not to use global variables is that it makes a program hard to debug.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
23
To assign a value to a global variable in a function, the global variable must first be declared in the function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
24
Which of the following functions returns the largest integer that is less than or equal to x?
A) floor
B) ceil
C) lesser
D) greater
A) floor
B) ceil
C) lesser
D) greater
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
25
What type of value is returned by the functions random and uniform?
A) integer
B) number
C) float
D) double
A) integer
B) number
C) float
D) double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
26
Different functions can have local variables with the same names.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
27
What makes it easier to reuse the same code in more than one program?
A) Mods
B) Procedures
C) Modules
D) Functions
A) Mods
B) Procedures
C) Modules
D) Functions
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
28
Python allows for passing multiple arguments to a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
29
Python function names follow the same rules for naming variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
30
The value assigned to a global constant can be changed in the mainline logic.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
31
A function definition specifies what a function does and causes the function to execute.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
32
The function header marks the beginning of the function definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
33
A local variable can be accessed from anywhere in the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
34
In a menu-driven program, what statement is used to determine and carry out the user's desired action?
A) if-else
B) if-elif-else
C) while
D) for
A) if-else
B) if-elif-else
C) while
D) for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
35
In a value-returning function, the value of the expression that follows the key word _____ will be sent back to the part of the program that called the function.
A) def
B) return
C) sent
D) result
A) def
B) return
C) sent
D) result
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
36
A value-returning function is _____.
A) a single statement that perform a specific task
B) called when you want the function to stop
C) a function that will return a value back to the part of the program that called it
D) a function that receives a value when it is called
A) a single statement that perform a specific task
B) called when you want the function to stop
C) a function that will return a value back to the part of the program that called it
D) a function that receives a value when it is called
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
37
The hierarchy chart shows all the steps that are taken inside a function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
38
What does the following statement mean?
Num1, num2 = get_num()
A) The function get_num() is expected to return a value each for num1 and num2.
B) The function get_num() is expected to return a value and assign it to num1 and num2.
C) Statement will cause a syntax error.
D) Statement will cause a run-time error.
Num1, num2 = get_num()
A) The function get_num() is expected to return a value each for num1 and num2.
B) The function get_num() is expected to return a value and assign it to num1 and num2.
C) Statement will cause a syntax error.
D) Statement will cause a run-time error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
39
What type of function can be used to determine whether a number is even or odd?
A) even
B) odd
C) math
D) Boolean
A) even
B) odd
C) math
D) Boolean
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
40
The Python standard library's _____ module contains numerous functions that can be used in mathematical calculations.
A) math
B) string
C) random
D) number
A) math
B) string
C) random
D) number
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
41
In Python, there is no restriction on the name of a module file.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
42
The top-down design breaks down the overall task of the program into a series of _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
43
Boolean functions are useful for simplifying complex conditions that are tested in decision and repetition structures.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
44
In a flowchart, a function call is depicted by a(n) _______________ that has vertical bars.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
45
The function header begins with the keyword _______________ followed by the name of the function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
46
Arguments are passed by _______________ to the corresponding parameter variables in the function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
47
A value-returning function is like a simple function except that when it finishes it returns a value back to the called part of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
48
Functions in the standard library are stored in files that are known as _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
49
Unlike other languages, in Python, the number of values a function can return is limited to one.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
50
The randrange function returns a randomly selected value from a specific sequence of numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
51
The main function contains a program's _______________ logic, which is the overall logic of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
52
A(n) _______________ chart is a visual representation of the relationships between functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
53
In a menu-driven program, a loop structure is used to determine the menu item the user selected.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
54
A variable is visible only to statements in the variable's _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
55
The math function, atan(x), returns one tangent of x in radians.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
56
The approach called _______________ is taking a large task and dividing it into several smaller tasks that are easily performed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
57
The math function, ceil(x), returns the smallest integer that is greater than or equal to x.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
58
The code for a function is known as a function _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
59
In Python, one can have a list of variables on the left side of the assignment operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
60
One of the drawbacks of a modularized program is that the only structure we could use is sequence structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
61
A(n) _______________ program displays a list of the operations on the screen and allows the user to select the operation that the program should perform.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
62
To refer to a function in a module, in our program we have to use the _______________ notation.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
63
In Python, a module's file name should end in _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
64
The approach of _______________ makes the program easier to understand, test, and maintain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
65
The return values of the trigonometric functions in Python are in _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
66
The _______________ chart is an effective tool that programmers use for designing and documenting functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
67
The 'P' in the acronym IPO refers to _______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
68
A value-returning function has a(n) _______________ statement that returns a value back to the part of the program that called it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck
69
The term _______________ is used to describe any mechanism that accepts input, performs some operation that cannot be seen, and produces output.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 69 في هذه المجموعة.
فتح الحزمة
k this deck