Python Certification Exam Preparation Set 59

What is the output of the following piece of code?


Options are :

  • False
  • True
  • Error as age isn't defined (Correct)
  • 7

Answer :Error as age isn't defined

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

Is the following piece of code valid?


Options are :

  • Yes, this method of calling is called bounded method call
  • Yes, this method of calling is called unbounded method call (Correct)
  • It isn't as there isn't any __init__ method for initializing class members
  • It isn't as the object declaration isn't right

Answer :Yes, this method of calling is called unbounded method call

The assignment of more than one function to a particular operator is _______


Options are :

  • Operator instance
  • Operator overriding
  • Operator overloading (Correct)
  • Operator over-assignment

Answer :Operator overloading

What is the output of the following piece of code?


Options are :

  • 1 1 1 (Correct)
  • '1' '1' '1'
  • An exception is thrown
  • 1 2 3

Answer :1 1 1

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

Method issubclass() checks if a class is a subclass of another class. True or False?


Options are :

  • True (Correct)
  • False

Answer :True

What is the output of the following code?


Options are :

  • Error
  • __repr__ called
  • __str__ called (Correct)
  • Nothing is printed

Answer :__str__ called

Which of the following will print True?


Options are :

  • class foo: def __init__(self, x): self.x = x def __less__(self, other): if self.x < other.x: return False else: return True
  • class foo: def __init__(self, x): self.x = x def __lt__(self, other): if self.x < other.x: return False else: return True
  • class foo: def __init__(self, x): self.x = x def __less__(self, other): if self.x > other.x: return False else: return True
  • class foo: def __init__(self, x): self.x = x def __lt__(self, other): if self.x < other.x: return True else: return False (Correct)

Answer :class foo: def __init__(self, x): self.x = x def __lt__(self, other): if self.x < other.x: return True else: return False

Python Certification Exam Preparation Set 31

Special methods need to be explicitly called during object creation. True or False?


Options are :

  • False (Correct)
  • True

Answer :False

What is the output of the following piece of code?


Options are :

  • 1 2 3 (Correct)
  • 1 1 1
  • '1' '1' '1'
  • An exception is thrown

Answer :1 2 3

What is the output of the following piece of code?


Options are :

  • Error because the proper syntax for name mangling hasn't been implemented
  • Error because the member shape is a protected member (Correct)
  • Error because the member shape is a private member
  • The program runs fine because name mangling has been properly implemented

Answer :Error because the member shape is a protected member

Python Certification Exam Preparation Set 54

What is the output of the code shown below?


Options are :

  • NameError
  • IndexError (Correct)
  • TypeError
  • ValueError

Answer :IndexError

What is the output of the following piece of code?


Options are :

  • 3 1 (Correct)
  • An exception in thrown
  • 0 1
  • 3 0

Answer :3 1

What is the output of the following piece of code?


Options are :

  • A
  • B (Correct)
  • An exception is thrown
  • A B

Answer :B

Python Certification Exam Preparation Set 53

What is the biggest reason for the use of polymorphism?


Options are :

  • There is less program code to write
  • Program code takes up less space
  • The program will have a more elegant design, and will be easier to maintain and update (Correct)
  • It allows the programmer to think at a more abstract level

Answer :The program will have a more elegant design, and will be easier to maintain and update

Which of the following is false about protected class members?


Options are :

  • They can be accessed by name mangling method (Correct)
  • They can be accessed within a class
  • They begin with one underscore
  • They can be accessed by subclasses

Answer :They can be accessed by name mangling method

Given the code fragment:

What is the result?


Options are :

  • An error is raised
  • 'It displays the passed argument' is printed (Correct)
  • disp.__doc__
  • None

Answer :'It displays the passed argument' is printed

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

Given the code fragment:

What is the result?


Options are :

  • Docstring 1
  • Docstring 2
  • func1.__doc__
  • None (Correct)
  • An error is raised

Answer :None

Given the code fragment:

What is the result?


Options are :

  • Python rocks!
  • Program terminates successfully but nothing is printed
  • An error is raised (Correct)

Answer :An error is raised

ASCII value of A is 65 and B is 66.


Given the code fragment:

What is the result?


Options are :

  • 131
  • 6566
  • AB (Correct)
  • An error is raised

Answer :AB

Python Certification Exam Preparation Set 13

Given the code fragment:

What is the result?


Options are :

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

Answer :[1, 2, 3] 3

Given the code fragment:

What is the result?


Options are :

  • 1
  • 2
  • 16
  • An error is raised (Correct)

Answer :An error is raised

Given the code fragment:

What is the result?


Options are :

  • 24
  • 48 (Correct)
  • 2
  • 8
  • An error is raised

Answer :48

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

Given:

Which of the following 2 options can be filled in the blank such that output will be 6?


Options are :

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

Answer :3, 2, 1 *[1, 2, 3]

Given:

Which of the following 2 options will replace the commented line such that output is 2.5?


Options are :

  • res = divide(1, num=5, den=2)
  • res = divide(1, 10, 4)
  • res = divide(den=2, num=5) (Correct)
  • res = divide(num=10, den=4) (Correct)

Answer :res = divide(den=2, num=5) res = divide(num=10, den=4)

Given the code fragment:

What is the result?


Options are :

  • Hello John Hello ('Olivia', 'Emma') Hello Alex
  • Hello John Hello Olivia Hello ('Emma', 'Alex')
  • Hello John Hello Olivia, Emma Hello Alex
  • Hello John Hello Olivia Hello Emma, Alex
  • An error is raised (Correct)

Answer :An error is raised

Python Certification Exam Preparation Set 19

Given:

For the above function, following calls were made:

1. test()

2. test(1)

3. test(2, 3)

4. test(first='udayan', last='khattry')

5. test(100, year=2018)


Which of the following statement is true?


Options are :

  • 2, 3 & 5 will execute successfully and 1 & 4 will fail
  • 1 & 4 will execute successfully and 2, 3 & 5 will fail
  • Only 5 will execute successfully
  • All 1, 2, 3, 4, & 5 will execute successfully (Correct)
  • 1 will fail and 2, 3, 4 & 5 will execute successfully

Answer :All 1, 2, 3, 4, & 5 will execute successfully

Given the code fragment:

What is the result?


Options are :

  • ONE ONE ONE ONE
  • ONE ONE ONE
  • ONE ONE
  • ONE (Correct)

Answer :ONE

Given the code fragment:

What is the result?


Options are :

  • ONE TWO ONE ONE
  • TWO TWO TWO
  • TWO ONE ONE
  • ONE TWO (Correct)

Answer :ONE TWO

Python Certification Exam Preparation Set 63

Given the code fragment:

What is the result?


Options are :

  • 5 7 5 5
  • 5 7 7 7
  • 7 5 (Correct)
  • 5 7
  • 5 7 7
  • 5 7 5

Answer :7 5

Given the code fragment:

What is the result?


Options are :

  • ([],)
  • (['a'],) (Correct)
  • (['a', 'b'],)
  • (['b'],)

Answer :(['a'],)

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions