1-- A function that returns an integer value grater than 0 is called a boolean f
ID: 3840592 • Letter: 1
Question
1-- A function that returns an integer value grater than 0 is called a boolean function.
Select one:
True
False
2-- Encapsulation is the process of wrapping a piece of code in a function
Select one:
True
False
3-- Repeated execution of a set of programming statements is called repetitive execution.
Select one:
True
False
4-- A development approach that that is intended to avoid a lot of debugging by only adding and testing small amounts of code at a time is called.
Select one:
a. structured development
b. incremental development
c. unit testing
d. Systems development life cycle
5-- What output will the following code produce?
def area(l, w):
temp = l * w;
return temp
l = 4.0
w = 3.25
x = area(l, w)
if ( x ):
print (x)
Select one:
a. 13.0
b. 0
c. Expression does not evaluate to boolean true
d. 13
6-- What output will the following code produce?
n = 10
while n != 1:
print (n,)
if n % 2 == 0: # n is even
n = n // 2
else: # n is odd
n = n * 3 + 1
Select one:
a. 10 5 16 8 4 2
b. None an error will be displayed
c. 8 4 2
d. 9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2
7-- What output will the following statements produce using Python IDLE in interactive mode?
>>> n = 2
>>> n += 5
>>> n
Select one:
a. 7
b. 5
c. 2
d. an error message will occur
8-- The statements inside of a loop are known as the ____ of the loop.
Select one:
a. body
b. expression
c. counter
d. block
9-- A loop where the terminating condition is never achieved is called an _______
Select one:
a. infinite loop
b. universal loop
c. while loop
d. for .. ever loop
10-- Functions can only return Boolean expressions.
Select one:
True
False
11-- With built in functions, it is generally acceptable to take a "Leap of Faith".
Select one:
True
False
12-- "Dead code" is code that performs calculations but never displays the results.
Select one:
True
False
13-- Boolean expressions control _________________
Select one:
a. recursion
b. conditional execution
c. alternative execution
d. all of the above
14-- The modulus operator is the same as the divide operator.
Select one:
True
False
15-- Chained conditionals are used when there are three or more possibilities.
Select one:
True
False
Explanation / Answer
1.
The statement “A function that returns an integer value greater than 0 is called a Boolean function” is False
Explanation:
Let’s take an example of an integer function like: int fact(int n). This function will return an integer value greater than 0 but a Boolean function returns only two values: true or false.
2.
The statement “Encapsulation is the process of wrapping a piece of code in a function” is True.
Explanation:
Encapsulation means wrapping data/ information in a single unit.
3.
The statement “Repeated execution of a set of programming statements is called repetitive execution” is False.
Explanation: Repeated execution of a set of programming statements is called iteration.
4.
A development approach that is intended to avoid a lot of debugging by only adding and testing small amounts of code at a time is called incremental development.
So, option b) is correct.
Explanation:
In incremental development, a small amount of code is added and tested to avoid time involved in debugging.
5.
The output of the following procedure will be 13.0.
The correct option is a.
Explanation: Here, l = 4.0, w = 3.25, x=area (4.0, 3.25), since x is true so the value will be calculated in temp variable as 4.0*3.25 and finally 13.0 will be printed.
6.
The output produced by the given code will be 10 5 16 8 4 2. So, the correct option is a.)
Explanation: The initial value of n is 10, now until the value of n becomes 1, check whether n is an even number, if it is even, divide n by 2. If n is odd, perform the calculation as n = n*3+1. Here, the initial value is 10 which is even so it is divided by 2, the value now becomes 5 which is odd so, n = 5*3+1 = 16, n becomes 16 which is even. Now again, 16 is divided by 2, the value obtained will be 8, then 4, then 2 and finally 1
So, 10 5 16 8 4 2 will be printed.
7.
The output that the following statements will produce using Python IDLE in interactive mode is 7.
The correct option is a)
Explanation: Here, the initial value of n is 2 in which 5 is added making the value of n as 7.
8.
The statements inside of a loop are known as the body of the loop.
The correct option is a.
Explanation: Take a loop as follows:
for (int i = 0;i<n; i++)
{
//body of the loop.
}
9.
A loop where the terminating condition is never achieved is called an infinite loop.
The correct option is a)
Explanation:
In an infinite loop, there is no functional exit, so it will repeat again and again.
10.
The statement “Functions can only return Boolean expressions” is False.
Explanation: Functions can also return integer, float, long, Boolean expressions
11.
The statement “With built in functions, it is generally acceptable to take a “Leap of Faith” is True.
Explanation: With built-in-functions, the result is already known.
12.
The statement “Dead code is code that performs calculations but never displays the results” is False.
Explanation: “Dead code” is the code which is not reachable or it cannot be executed, so it will not display result.
13.
Boolean expressions control all of the above.
The correct option is d)
Explanation: The Boolean expressions control recursion, conditional execution, alternative execution.
14.
The statement “The modulus operator is the same as the divide operator” is False
Explanation: The modulus operator is not the same as the divide operator. The modulus operator gives the remainder while the divide operator will give the quotient.
For example: 5%2 = 1
5/2 = 2.5
15.
The statement “Chained conditionals are used when there are three or more possibilities’ is True
Explanation:
Take the example as: if->else-if->else. There are 3 or more possibilities so it is a chained conditional.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.