1- What does function subroutine do? def subroutine( n ): while n > 0: print (n,
ID: 3837277 • Letter: 1
Question
1- What does function subroutine do?
def subroutine( n ):
while n > 0:
print (n,)
n -= 1
Select one:
a. Counts from 10 down to 0 and displays each number
b. Counts from n down to 1 and displays each number
c. Calculates the sum of n numbers greater than 0
d. Calculates the mean of n
---------------------------------------------------------------------------------------------------------
2- What output will the following python command produce:
>>> percentage = float ( 60 * 100) / 55
>>> print (percentage)
Select one:
a. percentage
b. 109
c. 109.0909090909091
d. 109.0
---------------------------------------------------------------------------------------------------------
3- What output will the following python commands produce:
n = 10000
count = 0
while n:
count = count + 1
n = n // 10
print (count)
Select one:
a. 5
b. 0
c. 10000
d. 1000
---------------------------------------------------------------------------------------------------------
4- What output will the following python commands produce:
x = 5
if x % 2 == 0:
print (x)
else:
print (x, x%2)
Select one:
a. 5
b. 5 1
c. 2
d. 5 0
---------------------------------------------------------------------------------------------------------
5- What does function subroutine do?
def subroutine(n):
while n > 0:
print (n,)
n -= 1
Select one:
a. Counts from 10 down to 0 and displays each number
b. Counts from n down to 1 and displays each number
c. Calculates the sum of n numbers greater than 0
d. Calculates the mean of n
---------------------------------------------------------------------------------------------------------
6- What is the output of the following statements?
pi = float(3.14159)
print (pi)
Select one:
a. 3
b. 3.0
c. 3.14159
d. 0
---------------------------------------------------------------------------------------------------------
7- What is the output of the following statements?
pi = int(3.14159)
print (pi)
Select one:
a. 3
b. 3.0
c. 3.14159
d. 0
---------------------------------------------------------------------------------------------------------
8- Expressions evaluate to either true or false. What will the output of the following code be when the expression “Ni!” is evaluated?
if "Ni!":
print ('We are the Knights who say, "Ni!"')
else:
print ("Stop it! No more of this!")
Select one:
a. Stop it!
b. We are the Knights who say, "Ni!"
c. Stop it! No more of this!"
d. No output will be produced
---------------------------------------------------------------------------------------------------------
9- What output will the following python commands produce:
x=1
y=2
if x == y:
print (x, "and", y, "are equal")
else:
if x < y:
print (x, "is less than", y)
else:
print (x, "is greater than", y)
Select one:
a. 1 and 2 are equal
b. 1 is less than 2
c. 1 is greater than 2
d. 2 is greater than 1
---------------------------------------------------------------------------------------------------------
10- The following code is an example of what principle?
bruce = 5
print (bruce,)
bruce = 7
print (bruce)
Select one:
a. Multiple assignment
b. An Iteration or loop structure
c. A logical operator
d. A conditional expression
---------------------------------------------------------------------------------------------------------
11- True/False: The % or modulus operator returns the remainder present when two integers do not divide evenly into one another
Select one:
True
False
---------------------------------------------------------------------------------------------------------
12- True/False: An algorithm is a step by step process for solving a problem.
Select one:
True
False
---------------------------------------------------------------------------------------------------------
13- Functions allow the programmer to encapsulate and generalize sections of code.
Select one:
True
False
---------------------------------------------------------------------------------------------------------
14- One way to generalize a function is to replace a variable with a value.
Select one:
True
False
---------------------------------------------------------------------------------------------------------
15- A variable name defined in a function cannot appear in the calling program because it will cause a conflict error.
Select one:
True
False
Explanation / Answer
Question 1
Answer: b. Counts from n down to 1 and displays each number
Question 2
Answer: c. 109.0909090909091
Question 3
Answer: a. 5
Question 4
Answer: b. 5 1
Question 5
Answer:b. Counts from n down to 1 and displays each number
Question 6
Answer: c. 3.14159
Question 7
Answer: a. 3
Question 8
Answer: b. We are the Knights who say, "Ni!"
Question 9
Answer: b. 1 is less than 2
Question 10
Answer: a. Multiple assignment
Question 11
Answer: True
Question 12
Answer: True
Question 13
Answer:
True
Question 14
Answer: False
Question 15
Answer: false
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.