UPDATED ACTUAL Exam Questions and
CORRECT Answers
Generator - CORRECT ANSWER A Python generator is a piece of specialized code able
to produce a series of values, and to control the iteration process, often called iterators
the range() function is a... - CORRECT ANSWER generator (iterator)
A generator returns a ____ of values - CORRECT ANSWER series
__iter__() - CORRECT ANSWER which should return the object itself and which is
invoked once (it's needed for Python to successfully start the iteration)
__next__() - CORRECT ANSWER which is intended to return the next value (first,
second, and so on) of the desired series - it will be invoked by the for/in statements in order to
pass through the next iteration; if there are no more values to provide, the method should raise
the StopIteration exception.
You use lambda to... - CORRECT ANSWER simplify the code, to make it clear and easier
to understand
Lambda is a ____________ function - CORRECT ANSWER anonymous (a function
without a name)
The structure of the declaration of a lambda function - CORRECT ANSWER lambda
parameters: expression
What is the results of....
double = lambda x: 2 * x
,print(double(2)) - CORRECT ANSWER 4
list() - CORRECT ANSWER transforms a series of subsequent generator invocations into
a real list
Does the in operator allow you to use a generator? - CORRECT ANSWER Yes
list comprehension - CORRECT ANSWER a simple and very impressive way of creating
lists and their contents. Such as
list_2 = [10 ** ex for ex in range(6)]
conditional expression - CORRECT ANSWER a way of selecting one of two different
values based on the result of a Boolean expression. Such as
list.append(1 if x % 2 == 0 else 0)
map(a, b) - CORRECT ANSWER a = function
b = list
applies the function passed to all of its second arguments elements, and returns an iterator
delivering all subsequent function results
filter(a, b) - CORRECT ANSWER Filters b while being guided by directions flowing from
the function specified as the first argument
Closures - CORRECT ANSWER a technique which allows the storing of values in spite of
the fact that the context in which they have been created does not exist anymore
Is it possible to declare a closure equipped with an arbitrary number of parameters - CORRECT
ANSWER Yes, this means it can also modify its behaviour by using values from the
outside
, Different operating systems treat files in ________ ____ - CORRECT ANSWER Different
ways
Windows (notation of a canonical file name) - CORRECT ANSWER C:\directory\file
Linux (notation of a canonical file name) - CORRECT ANSWER /directory/files
The main difference between Linux's and Windows's (notation of a canonical file name) -
CORRECT ANSWER two different separators for the directory names (\ in Windows, / in
Unix/Linux)
In python file names need to be written as... - CORRECT ANSWER name = '\\dir\\file'
Can python convert slashes into backslashes each time it discovers that it's required by the OS -
CORRECT ANSWER Yes, for example...
name = '/dir/file'
name = 'c:/dir/file'
both work
The operation of connecting the stream with a file is called...
And disconnecting this link is called.... - CORRECT ANSWER opening the file
closing the file
If the opening is successful, the program will be allowed to perform only... - CORRECT
ANSWER the operation which are consistent with the declared open mode
The two basic operations performed on the stream. - CORRECT ANSWER read - from the
streams: the portions of the data are received from the file and placed in a memory area managed
by the program
write - to the stream: the portions of the data from the memory are transferred to the file