Python Certification Exam Preparation Set 67

What is the length of sys.argv?


Options are :

  • number of arguments
  • number of arguments + 1 (Correct)
  • number of arguments - 1
  • none of the mentioned

Answer :number of arguments + 1

How are keyword arguments specified in the function heading?


Options are :

  • one-star followed by a valid identifier
  • one underscore followed by a valid identifier
  • two stars followed by a valid identifier (Correct)
  • two underscores followed by a valid identifier

Answer :two stars followed by a valid identifier

What will be the output of the following Python code?


Options are :

  • 3 1 (Correct)
  • 1 3
  • error
  • none of the mentioned

Answer :3 1

Python Certification Exam Preparation Set 4

What will be the output of the following Python code?


Options are :

  • 0
  • 1 (Correct)
  • error
  • none of the mentioned

Answer :1

What will be the output of the following Python code?


Options are :

  • True
  • False (Correct)
  • None
  • Error

Answer :False

What will be the output of the following Python code?


Options are :

  • [0] [1] [2]
  • [0] [0, 1] [0, 1, 2] (Correct)
  • [1] [2] [3]
  • [1] [1, 2] [1, 2, 3]

Answer :[0] [0, 1] [0, 1, 2]

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

What will be the output of the following Python code?


Options are :

  • 4
  • 5 (Correct)
  • 1
  • An exception is thrown

Answer :5

What will be the output of the following Python code?


Options are :

  • An exception is thrown because of conflicting values
  • 1 2
  • 3 3
  • 3 2 (Correct)

Answer :3 2

What will be the output of the following Python code?


Options are :

  • Integer
  • Tuple (Correct)
  • Dictionary
  • An exception is thrown

Answer :Tuple

Python Certification Exam Preparation Set 36

If a function doesn't have a return statement, which of the following does the function return?


Options are :

  • int
  • null
  • None (Correct)
  • An exception is thrown without the return statement

Answer :None

What is setattr() used for?


Options are :

  • To access the attribute of the object
  • To set an attribute (Correct)
  • To check if an attribute exists or not
  • To delete an attribute

Answer :To set an attribute

What are the methods which begin and end with two underscore characters called?


Options are :

  • Special methods (Correct)
  • In-built methods
  • User-defined methods
  • Additional methods

Answer :Special methods

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

Which of these is a private data field?

def Demo:

def __init__(self):

__a = 1

self.__b = 1

self.__c__ = 1

__d__= 1


Options are :

  • __a
  • __b (Correct)
  • __c__
  • . __d__

Answer :__b

When will the else part of try-except-else be executed?


Options are :

  • always
  • when an exception occurs
  • when no exception occurs (Correct)
  • when an exception occurs in to except block

Answer :when no exception occurs

What is the output of the code shown below?

def f(x):

yield x+1

print("test")

yield x+2

g=f(9)


Options are :

  • Error
  • test
  • test1012
  • No output (Correct)

Answer :No output

Python Certification Exam Preparation Set 50

The output of the code shown below is:


int('65.43')


Options are :

  • ImportError
  • ValueError (Correct)
  • TypeError
  • NameError

Answer :ValueError

What is the output of the following piece of code?

class A():

def disp(self):

print("A disp()")

class B(A):

pass

obj = B()

obj.disp()


Options are :

  • Invalid syntax for inheritance
  • Error because when object is created, argument must be passed
  • Nothing is printed
  • A disp() (Correct)

Answer :A disp()

Which of the following statements is true?


Options are :

  • The __new__() method automatically invokes the __init__ method
  • The __init__ method is defined in the object class
  • The __eq(other) method is defined in the object class (Correct)
  • The __repr__() method is defined in the object class

Answer :The __eq(other) method is defined in the object class

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

Which function overloads the == operator?


Options are :

  • __eq__() (Correct)
  • __equ__()
  • __isequal__()
  • none of the mentioned

Answer :__eq__()

What is the output of the following piece of code?


class Demo:

def __init__(self):

self.x = 1

def change(self):

self.x = 10

class Demo_derived(Demo):

def change(self):

self.x=self.x+1

return self.x

def main():

obj = Demo_derived()

print(obj.change())


main()


Options are :

  • 11
  • 2
  • 1
  • . An exception is thrown (Correct)

Answer :. An exception is thrown

What is the result of the expression if x=15 and y=12:


Options are :

  • b1101
  • 0b1101
  • 12 (Correct)
  • 1101

Answer :12

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

Which of the following represents the bitwise XOR operator?


Options are :

  • &
  • ^ (Correct)
  • |
  • !

Answer :^

What is the value of this expression:

bin(10-2)+bin(12^4)


Options are :

  • 0b10000
  • 0b10001000
  • 0b1000b1000
  • 0b10000b1000 (Correct)

Answer :0b10000b1000

What is the two's complement of -44?


Options are :

  • 1011011
  • 11010100 (Correct)
  • 11101011
  • 10110011

Answer :11010100

Python Certification Exam Preparation Set 60

What is the output of the code shown below?


not(3>4)

not(1&1)


Options are :

  • TrueTrue
  • TrueFalse (Correct)
  • FalseTrue
  • FalseFalse

Answer :TrueFalse

What is the output of the code shown below?

class Truth:

pass

x=Truth()

bool(x)


Options are :

  • pass
  • true (Correct)
  • false
  • error

Answer :true

What is the value of the following expression?

2+4.00, 2**4.0


Options are :

  • (6.0, 16.0) (Correct)
  • (6.00, 16.00)
  • (6, 16)
  • (6.00, 16.0)

Answer :(6.0, 16.0)

Python Certification Exam Preparation Set 24

What is the value of x if:


x = int(43.55+2/2)


Options are :

  • 43
  • 44 (Correct)
  • 22
  • 23

Answer :44

What is the value of the expression:


4+2**5//10


Options are :

  • 3
  • 7 (Correct)
  • 77
  • 0

Answer :7

What is the value of the following expression:

24//6%3, 24//4//2


Options are :

  • (1,3) (Correct)
  • (0,3)
  • (1,0)
  • (3,1)

Answer :(1,3)

Python Certification Exam Preparation Set 21

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions