Pregunta 1
Pregunta
Examine the code and determine the value of the variable b when the code completes.
Pregunta 2
Pregunta
Examine the code and determine the output.
Respuesta
-
{}
-
foo
-
{'obj_name': 'foo'}
-
{'obj_name' = 'foo'}
Pregunta 3
Pregunta
What output will be produced from this snippet of code?
Respuesta
-
IndexError
-
[]
-
['a', 'b', 'c', 'd', 'e']
Pregunta 4
Pregunta
What is the difference between a tuple and a list?
Pregunta 5
Pregunta
What output will be produced?
Pregunta 6
Pregunta
Is a list a heterogeneous data structure in Python?
Pregunta 7
Pregunta
If a list is mutable in Python, can it hold immutable objects?
Pregunta 8
Pregunta
A tuple is an immutable data structure in Python. Can it hold mutable objects?
Pregunta 9
Pregunta
What is the value of variable d when the code completes?
Respuesta
-
[1, 'Dublin', 2, 'London', 3, 'Moscow']
-
{1: 'Dublin', 2: 'London', 3: 'Moscow'}
-
An exception is raised
Pregunta 10
Pregunta
Is the code performing legal operations?
Pregunta 11
Pregunta
Do a and b return the same object type?
Pregunta 12
Pregunta
Determine the value of the variable b when the code completes?
Respuesta
-
[10,20,30]
-
20
-
[10, 20, 50]
Pregunta 13
Pregunta
What is the output from this code?
Pregunta 14
Pregunta
What is the output of the code?
Pregunta 15
Pregunta
What is the output of the code?
Respuesta
-
'age under 30'
-
'age equals 25'
-
None of the above
Pregunta 16
Pregunta
Determine the output of the code?
Respuesta
-
{house:1215}, 'apt
-
An exception is raised
-
'apt', {house:1215}
Pregunta 17
Pregunta
What is the output?
Respuesta
-
0 2
-
john sarah
-
An exception is raised
Pregunta 18
Pregunta
Which line of code is correct to detect if a variable is a function?
Respuesta
-
hasattr(obj, '__call__')
-
isinstance(x, function)
-
type(x) == 'function'
Pregunta 19
Pregunta 20
Pregunta
What is the value of the variable name when the code completes?
Pregunta 21
Pregunta
What is the "__init__.py" file for in a Python source directory?
Pregunta 22
Pregunta
Is new_list a shallow or deep copy of old_list?
Pregunta 23
Pregunta
Determine what the output will be?
Respuesta
-
['j','o','h','n']
-
'John'
-
'mylist'
Pregunta 24
Pregunta
What is the output of the code?
Pregunta 25
Pregunta
Determine the value of a after the method is called twice.
Pregunta 26
Pregunta
Determine the output of the code?
Pregunta 27
Pregunta
What is the output of the code?
Pregunta 28
Pregunta
What is the output of the code?
Pregunta 29
Pregunta
I want to read from a file on the path 'C:\newfile\textfile.txt'. What is the correct way to open the file?
Respuesta
-
myfile = open('C:\newfile\textfile.txt', 'r')
-
myfile = open(r'C:\newfile\textfile.txt', 'r')
Pregunta 30
Pregunta
Review the code. Does the variable a have a type? If so, what is the type of a?
Respuesta
-
Variable a does not have a type
-
Variable a is of type List
-
Variable a is of type String
Pregunta 31
Pregunta
Is that code legal?
Pregunta 32
Pregunta
Determine the result?
Pregunta 33
Pregunta
Is the code legal or illegal?
Pregunta 34
Pregunta
What is the result of the code?
Pregunta 35
Pregunta
What output does the code produce?
Respuesta
-
['jack', 'peter', 'sarah']
-
['sarah']
-
[ 'sarah', 'peter', jack']
Pregunta 36
Pregunta
Analyse the code and determine the result
Pregunta 37
Pregunta
What is the output?
Respuesta
-
[10]
-
raises an exception
-
[[10]]
Pregunta 38
Pregunta
What object types do variables a and b point to?