Test
CS 1101 Week 5
Preguntas del test (13)
1What does the function subroutine do?
def subroutine(n):
while n>0:
print(n,)
n-=1- ACounts down from 10 to 0 and displays each number
- BCounts from n down to 1 and displays each number
- CCalculates the sum of n numbers greater than 0
- DCalculates the mean of n
2What output will the following python command produce:
>>>percentage = float (60*100)/50
>>>print(percentage)- Apercentage
- B109
- C109.0909090909091
- D109.0
3What outputs will the following python commands produce:
n=10000
count=0
while n:
count=count+1
n=n//10
print(count)- A5
- B0
- C10000
- D1000
4What output will the following python commands produce:
x=5
if x%2==0:
print(x)
else:
print(x,x%2)- A5
- B5 1
- C2
- D5 0
5What is the output of the following statements?
pi=float(3.14159)
print(pi)- A3
- B3.0
- C3.14159
- D0
6Expressions 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!")- AStop it!
- BWe are the knights who say, "Ni!"
- CStop it! No more of this!
- DNo output will be produced
7What 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)- A1 and 2 are equal
- B1 is less than 2
- C1 is greater than 2
- D2 is greater than 2
8The following code is an example of what principle?
bruce=5
print(bruce,)
bruce=7
print(bruce)- AMultiple Assignment
- BAn iteration or loop structure
- CA logical operator
- DA conditional operator
9The % or modulus operator returns the remainder present when two integers do not divide evenly into one another
- AVerdadero
- BFalso
10An algorithm is a step by step process for solving a problem
- AVerdadero
- BFalso
11Functions allow the programmer to encapsulate and generalize sections of code.
- AVerdadero
- BFalso
12One way to generalize a function is to replace a variable with a value.
- AVerdadero
- BFalso
13A variable name defined in a function cannot appear in the calling program because it will cause a conflict error.
- AVerdadero
- BFalso
Información
- Descripción
- AS - Level (CS 1101 Python) Computer Science Test sobre CS 1101 Week 5 , creado por Troy Bowlin el 18/05/2016.
- Autor
- Troy Bowlin
- Idioma
- English
- Visitas
- 159
- Etiquetas
- Valoración
- Aún sin valoraciones Valora este test