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