Troy Bowlin
Quiz por , criado more than 1 year ago

AS - Level Computer Science (CS 1101 Python) Quiz sobre CS 1101 Week 4 , criado por Troy Bowlin em 01-05-2016.

113
1
0
Troy Bowlin
Criado por Troy Bowlin aproximadamente 8 anos atrás
Fechar

CS 1101 Week 4

Questão 1 de 14

1

One of the advantages of a function is that it allows the programmer to alter the flow of the execution in the program

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 2 de 14

1

A stack diagram shows the value of each variable and the function to which each variable belongs

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 3 de 14

1

The graphical representation of a stack of functions, their variables, and the values to which they refer is called a traceback.

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 4 de 14

1

A local variable is a variable defined inside a function that can only be used inside its function.

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 5 de 14

1

What will the output of this python program be?
def test_function(length, width, height):
print ("the area of the box is ",length*width*height)
return length*width*height

l = 12.5
w = 5
h = 2
test_function(l,w,h)

Selecione uma das seguintes:

  • The area of the box is 125

  • The area of the box is 125.0

  • The area of the box is 120

  • 125.0

Explicação

Questão 6 de 14

1

What will the output of this program be when it is executed?

def test_function( length, width, height):
print ("the area of the box is ", length*width*height)
return length*width*height

l = 12.5
w = 5
h = 2
test_function(l, w, h)

print ("The area of the box is ", length*width*height)

Selecione uma das seguintes:

  • A NameError because a variable is not defined

  • The area of the box is 125.0

  • The are of the box is 0

  • A SyntaxError due to illegal function call

Explicação

Questão 7 de 14

1

What will the output of the following code be?

def recursive( depth ):
depth+=1
while (depth < 5):
ret = recursive(depth)
return depth

ret = recursive( 0 )
print ("the recursive depth is ", ret)

Selecione uma das seguintes:

  • The recursive depth is 5

  • The recursive depth is 4

  • Error due to depth of recursive calls

  • None

Explicação

Questão 8 de 14

1

What will the output of the following program be?

i=0
while (i < max(1, 22-4*5, 3*5-3*4, 2**2)):
i+=1
print (i)

Selecione uma das seguintes:

  • 0

  • 5

  • 3

  • 4

Explicação

Questão 9 de 14

1

What output will the following Python script produce?

def function2(param):
print (param, param)

def function1(part1, part2):
cat = part1 + part2
function2(cat)

chant1 = "See You"
chant2 = "See Me"
function1(chant1, chant2)

Selecione uma das seguintes:

  • See You See Me

  • See You See Me See You See Me

  • See Me See Me See You See You

  • None it would generate an error

Explicação

Questão 10 de 14

1

What does the import statement in the following script do?

import StringIO
output = StringIO.StringIO()
output.write('First line.\n')
output.close()

Selecione uma das seguintes:

  • It imports data into the script

  • It changes the format of the string in the script

  • It opens a file for StringIO functions to read

  • It includes a Python module called StringIO into the script

Explicação

Questão 11 de 14

1

The following Python script will generate an error when executed. What is the cause of the error?

def function2(param):
print (param, param)
print (cat)

def function1(part1, part2):
cat = part1 + part2
function2(cat)

chant1 = "See You"
chant2 = "See Me"
function1(chant1, chant2)

Selecione uma das seguintes:

  • The variable cat is local to function1 and cannot be used in function 2

  • The variable param is used twice in function2 and this is illegal

  • Function2 does not have a return value defined

  • Function1 does not have a return value defined

Explicação

Questão 12 de 14

1

Dot notation is reserved for variable names and cannot be used to call a function

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 13 de 14

1

Functions always get executed first regardless to the flow of execution

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação

Questão 14 de 14

1

The 80286 microprocessor was introduced in Feb '82 and was four times more powerful than the 8088

Selecione uma das opções:

  • VERDADEIRO
  • FALSO

Explicação