Python Certification Exam Preparation Set 37

What is the output of this expression, 3*1**3?


Options are :

  • 27
  • 3 (Correct)
  • 9
  • 1

Answer :3

Why are local variable names beginning with an underscore discouraged?


Options are :

  • they slow down execution
  • they are used to indicate a private variables of a class (Correct)
  • they are used to indicate global variables
  • they confuse the interpreter

Answer :they are used to indicate a private variables of a class

Suppose d = {"john":40, "peter":45}. To obtain the number of entries in dictionary which command do we use?


Options are :

  • d.len()
  • d.size()
  • size(d)
  • len(d) (Correct)

Answer :len(d)

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

What will be the output of the following Python code?


Options are :

  • Error as the duplicate item 6 is present in both sets
  • Error as unsupported operand type for set data type
  • {4,5} (Correct)
  • {6}

Answer :{4,5}

What will be the output of the following Python code snippet?


Options are :

  • None
  • True
  • False (Correct)
  • Error

Answer :False

If a={5,6,7}, what happens when a.add(5) is executed?


Options are :

  • Error as there is no add function for set data type
  • a={5,5,6,} (Correct)
  • a={5,5,6,7}
  • Error as 5 already exists in the set

Answer :a={5,5,6,}

Python Certification Exam Preparation Set 38

Which of the following is the use of function in python?


Options are :

  • Functions don't provide better modularity for your application
  • you can't also create your own functions
  • All of the mentioned
  • Functions are reusable pieces of programs (Correct)

Answer :Functions are reusable pieces of programs

What will be the output of the following Python code snippet?


Options are :

  • True False (Correct)
  • True True
  • False True
  • False False

Answer :True False

What will be the output of the following Python code snippet?


Options are :

  • "john"
  • 40 (Correct)
  • "peter"
  • 45

Answer :40

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

What will be the output of the following Python function?


Options are :

  • False (Correct)
  • 0
  • True
  • Error

Answer :False

What will be the output of the following Python code snippet?


Options are :

  • "john", 40, 45, and "peter"
  • 40 and 45
  • "john" and "peter" (Correct)
  • d = (40:"john", 45:"peter")

Answer :"john" and "peter"

What is the type of each element in sys.argv?


Options are :

  • list
  • tuple
  • set
  • string (Correct)

Answer :string

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

What will be the output of the following Python code?


Options are :

  • Hello World,World,World,World,World
  • Hello World 5
  • Hello HelloHelloHelloHelloHello
  • Hello WorldWorldWorldWorldWorld (Correct)

Answer :Hello WorldWorldWorldWorldWorld

Which of the following is a feature of DocString?


Options are :

  • Provide a convenient way of associating documentation with Python modules, functions, classes, and methods
  • All of the mentioned (Correct)
  • All functions should have a docstring
  • Docstrings can be accessed by the __doc__ attribute on objects

Answer :All of the mentioned

Which of the following functions is a built-in function in python?


Options are :

  • print() (Correct)
  • factorial()
  • sqrt()
  • seed()

Answer :print()

Python Certification Exam Preparation Set 27

What will be the output of the following Python function?


Options are :

  • False
  • 4>2
  • Error
  • True (Correct)

Answer :True

Suppose d = {"john":40, "peter":45}, to delete the entry for "john" what command do we use?


Options are :

  • d.delete("john":40)
  • del d("john":40)
  • d.delete("john")
  • del d["john"] (Correct)

Answer :del d["john"]

What will be the output of the following Python code?


Options are :

  • The numbers are equal
  • None of the mentioned
  • 2
  • 3 (Correct)

Answer :3

Python Certification Exam Preparation Set 63

What will be the output of the following Python code?


Options are :

  • Error as the duplicate item 6 is present in both sets
  • {4,5,6,2,8,6}
  • {4,5,6,2,8}
  • Error as unsupported operand type for sets (Correct)

Answer :Error as unsupported operand type for sets

What will be the output of the following Python code snippet?


Options are :

  • Error
  • False
  • None
  • True (Correct)

Answer :True

Which of the following statements create a dictionary?


Options are :

  • d = {"john":40, "peter":45}
  • d = {40:"john", 45:"peter"}
  • All of the mentioned (Correct)
  • d = {}

Answer :All of the mentioned

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

If a={5,6,7,8}, which of the following statements is false?


Options are :

  • a[2]=45 (Correct)
  • print(min(a))
  • print(len(a))
  • a.remove(5)

Answer :a[2]=45

What will be the output of the following Python code?


Options are :

  • Hello World! Hello World! (Correct)
  • 'Hello World!' 'Hello World!'
  • None of the mentioned
  • Hello Hello

Answer :Hello World! Hello World!

What will be the output of the following Python code?


Options are :

  • 4
  • None of the mentioned
  • 4 is maximum (Correct)
  • 3

Answer :4 is maximum

Python Certification Exam Preparation Set 8

Which keyword is used for function?


Options are :

  • Function
  • Define
  • Def (Correct)
  • Fun

Answer :Def

What will be the output of the following Python code?


Options are :

  • x is 50 Changed local x to 2 x is now 100
  • x is 50 Changed local x to 2 x is now 2
  • x is 50 Changed local x to 2 x is now 50 (Correct)
  • None of the mentioned

Answer :x is 50 Changed local x to 2 x is now 50

What will be the output of the following Python function?


Options are :

  • 5
  • 5.0 (Correct)
  • Error
  • -5

Answer :5.0

Python Certification Exam Preparation Set 64

What will be the output of the following Python code snippet?


Options are :

  • None
  • True
  • Error (Correct)
  • False

Answer :Error

What will be the output of the following Python expression?


Options are :

  • 4.57 (Correct)
  • 4.56
  • 4.5
  • 4.6

Answer :4.57

What will be the output of the following Python expression?


Options are :

  • 4
  • 4.5
  • 5 (Correct)
  • 4.6

Answer :5

Python Certification Exam Preparation Set 35

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions