Python Certification Exam Preparation Set 7

Which of following are valid file object attributes ?


Options are :

  • file.softspace
  • All of these (Correct)
  • file.closed
  • file.name
  • file.mode

Answer :All of these

Python Certification Exam Preparation Set 48

To open a file for reading, writing, appending only which file modes should be used ?


Options are :

  • r+,w+,a+
  • r,w,a (Correct)
  • rb,wb,ab
  • rb+,wb+,ab+

Answer :r,w,a

Python assumes that any variable assigned a value in a function is local.


Options are :

  • YES (Correct)
  • NO

Answer :YES

In which of following directories python interpreter searches for your imported module ?


Options are :

  • Current Directory
  • All of these (Correct)
  • default path
  • Each Directory in shell's/Environment PYTHONPATH variable

Answer :All of these

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 13

In Python you can access a class object's attributes using which operator?


Options are :

  • (>) Operator
  • (->) Operator
  • (.) dot operator (Correct)
  • (=>) Operator

Answer :(.) dot operator

What is default file opening mode?


Options are :

  • r+
  • rb+
  • r (Correct)
  • rb

Answer :r

"assert" satement was introduced in which python version


Options are :

  • 1.5 (Correct)
  • from begning
  • 3
  • 2.6

Answer :1.5

Python Certification Exam Preparation Set 64

To find your current position in a file, which method can be used


Options are :

  • offset()
  • tell() (Correct)
  • pos()
  • curr_pos()

Answer :tell()

Python allows user-defined exceptions.


Options are :

  • YES (Correct)
  • NO

Answer :YES

The Class Documentation string written in first line[class ClassName:], can be accessed via


Options are :

  • ClassName.__about__
  • ClassName.__doc__ (Correct)
  • ClassName.__desc__
  • ClassName.__info__

Answer :ClassName.__doc__

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 25

When the module is imported into a script, the code in the top-level portion of a module is executed only once. Using which function this top-level code can be re-executed ?


Options are :

  • restart()
  • reload() (Correct)
  • reexecute()
  • reimport()

Answer :reload()

A module is imported 3 times.How many time do you think it's loaded ?


Options are :

  • 3
  • ImportError: Miltipe imports of same module
  • 1 (Correct)
  • SyntaxError: Can't import previously imported module

Answer :1

To hide a class objects attributes outside of the clas, they must be prefixed by


Options are :

  • hide_
  • single underscore (_)
  • double underscore (__) (Correct)
  • hide__

Answer :double underscore (__)

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 2

Which of following are Valid functions regarding Class attributes


Options are :

  • getattr
  • All of these (Correct)
  • setattr
  • deattr
  • hasattr

Answer :All of these

To get a list of strings contaning the names define by the module, one can use which of following function ?


Options are :

  • funcs()
  • defines()
  • list_names()
  • dir() (Correct)

Answer :dir()

When an identifier is not found in the local or global namespace which of following error is raised ?


Options are :

  • SyntaxError
  • NamespaceError
  • VariableError
  • NameError (Correct)

Answer :NameError

Python Certification Exam Preparation Set 19

To open a file for both [reading and writing],[writing and reading] and [appending and reading] in binary format, which file modes should be used ?


Options are :

  • r,w,a
  • r+,w+,a+
  • rb,wb,ab
  • rb+,wb+,ab+ (Correct)

Answer :rb+,wb+,ab+

What can be the masked area ("?") in the following code if the code prints <class 'dict'>?


Options are :

  • None of the above
  • def guessTheParams({arg}, arg1, arg2):
  • def guessTheParams(arg, arg1, arg3):
  • def guessTheParams(**arg): (Correct)

Answer :def guessTheParams(**arg):

Python Certification Exam Preparation Set 11

What will the following code print?



Options are :

  • 6
  • 1 (Correct)
  • 5
  • None of the above

Answer :1

Which of the following is the best practice to return a statement.

Consider the scenario where you have a function which calculates the average of a list. The variable set is as following:

givenList  <type 'list'> for the list
avg <type 'float'> for the average


Options are :

  • return avg (Correct)
  • return "The average is: " + avg
  • return "The average of the list " + givenList + "is: " + avg
  • return return "The average is: " + str(avg)

Answer :return avg

What will the following code print?


Options are :

  • Error: function takes only one positional argument but
  • 1
  • None of the above
  • 6 (Correct)

Answer :6

Python Certification Exam Preparation Set 65

What will be the output of the code?


Options are :

  • functionOne functionOne (Correct)
  • functionTwo functionTwo
  • functionOne functionTwo
  • Invalid syntax

Answer :functionOne functionOne

Select the syntax of the anonymous function:


Options are :

  • name = anonymous arguments : operation
  • name = lambda arguments : operation (Correct)
  • name = lambda operation : arguments
  • name = lambda(arguments) -> operation

Answer :name = lambda arguments : operation

What is the group of the name of the function along with its arguments called?

[ in other words, what is line 1 called ]


Options are :

  • Function ID
  • Function Call
  • Function Definition
  • Function Signature (Correct)

Answer :Function Signature

Python Certification Exam Preparation Set 9

The concept used in the following pseudo code is...


Options are :

  • Decorators
  • Generators
  • Child function
  • Recursion (Correct)

Answer :Recursion

You can store an entire function in a variable and can execute with the newly defined variable name and with different arguments.


Options are :

  • True (Correct)
  • False

Answer :True

We can pass less arguments to the function then asked without getting any error...


Options are :

  • True (Correct)
  • False

Answer :True

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 28

What will the function print?


Options are :

  • 16
  • 400
  • 20
  • 25 (Correct)

Answer :25

What is the first line called?


Options are :

  • Generator
  • First order function
  • Decorator (Correct)
  • Closure

Answer :Decorator

The way you can change the behavior of any function is through


Options are :

  • Decorators (Correct)
  • Recursion
  • Modifiers
  • Generator

Answer :Decorators

Python Practice Test MCQ Certified Go from 0 to Expert hero Set 13

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions