Python Certification Exam Preparation Set 50

What is the output of the following?

print('a'.maketrans('ABC', '123'))


Options are :

  • {97: 49, 98: 50, 99: 51} (Correct)
  • {65: 49, 66: 50, 67: 51}
  • {97: 49}
  • 1

Answer :{97: 49, 98: 50, 99: 51}

Python Certification Exam Preparation Set 29

What is the output of the following?

print('xyyxyyxyxyxxy'.replace('xy', '12', 100))


Options are :

  • xyyxyyxyxyxxy
  • 12y12y1212x12 (Correct)
  • none of the mentioned
  • error

Answer :12y12y1212x12

What is the output of the following?

print('abcd'.translate({'a': '1', 'b': '2', 'c': '3', 'd': '4'}))


Options are :

  • abcd (Correct)
  • 1234
  • error
  • none of the mentioned

Answer :abcd

Which of the following statements is used to create an empty set?


Options are :

  • { }
  • set() (Correct)
  • [ ].
  • ( )

Answer :set()

Python Certification Exam Preparation Set 18

What is the output of the following piece of code when executed in the python shell?

a={1,2,3}

a.intersection_update({2,3,4,5})

a


Options are :

  • {2,3} (Correct)
  • Error, duplicate item present in list
  • Error, no method called intersection_update for set data type
  • {1,4,5}

Answer :{2,3}

Which of the following lines of code will result in an error?


Options are :

  • s={abs}
  • s={4, 'abc', (1,2)}
  • s={2, 2.2, 3, 'xyz'}
  • s={san} (Correct)

Answer :s={san}

What is the output of the code shown below?

s=set([1, 2, 3])

s.union([4, 5])

s|([4, 5])


Options are :

  • {1, 2, 3, 4, 5}{1, 2, 3, 4, 5}
  • Error{1, 2, 3, 4, 5}
  • {1, 2, 3, 4, 5}Error (Correct)
  • ErrorError

Answer :{1, 2, 3, 4, 5}Error

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

What is the output of the line of code shown below, if s1= {1, 2, 3}?

s1.issubset(s1)


Options are :

  • True (Correct)
  • Error
  • No output
  • False

Answer :True

Suppose t = (1, 2, 4, 3), which of the following is incorrect?


Options are :

  • print(t[3])
  • t[3] = 45 (Correct)
  • print(max(t))
  • print(len(t))

Answer :t[3] = 45

What will be the output?

d = {"john":40, "peter":45}

d["john"]


Options are :

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

Answer :40

Python Certification Exam Preparation Set 15

What is the output of the following piece of code when executed in Python shell?

a=("Check")*3

a


Options are :

  • ('Check','Check','Check')
  • * Operator not valid for tuples
  • ('CheckCheckCheck') (Correct)
  • Syntax error

Answer :('CheckCheckCheck')

Is the following piece of code valid?

a=2,3,4,5

a


Options are :

  • Yes, 2 is printed
  • Yes, [2,3,4,5] is printed
  • No, too many values to unpack
  • Yes, (2,3,4,5) is printed (Correct)

Answer :Yes, (2,3,4,5) is printed

What is the output of the following code?

a,b=6,7

a,b=b,a

a,b


Options are :

  • (6,7)
  • Invalid syntax
  • (7,6) (Correct)
  • Nothing is printed

Answer :(7,6)

Python Certification Exam Preparation Set 7

Is the following Python code valid?


Options are :

  • Yes, 2 is printed
  • Yes, [2,3,4,5] is printed
  • No, too many values to unpack
  • Yes, (2,3,4,5) is printed (Correct)

Answer :Yes, (2,3,4,5) is printed

What will be the output of the following Python code?


Options are :

  • (1,2,3,5)
  • (2,3,1,5)
  • None
  • Error, tuple has no attribute sort (Correct)

Answer :Error, tuple has no attribute sort

What will be the output of the following Python code?


Options are :

  • [(1, 2), (2, 4), (3, 9)] (Correct)
  • [(2,4),(1,2),(3,9)]
  • Error because tuples are immutab
  • Error, tuple has no sort attribute

Answer :[(1, 2), (2, 4), (3, 9)]

Python Certification Exam Preparation Set 31

What is CPython?


Options are :

  • It is just another name of Cython
  • A compiled language used to perform high level functions
  • The default implementation of the Python programming language (Correct)

Answer :The default implementation of the Python programming language

Python Certification Exam Preparation Set 53

Which of the following is the correct file extension for Python file?


Options are :

  • .pn
  • .p
  • .pi
  • .py (Correct)

Answer :.py

Which of the following statement is incorrect with respect to Lists and Tuples?


Options are :

  • Lists are mutable
  • Tuples are immutable
  • Lists and Tuples are both sequence data types
  • List and Tuples are both mutable (Correct)

Answer :List and Tuples are both mutable

Select the correct output of the code if you input 23 and 22 respectively.


Input1 = input("Enter the first number: ") # Enter 23

Input2 = input("Enter the second number: ") # Enter 22


print(Input1 + Input2)


Options are :

  • 23+22
  • 2322 (Correct)
  • 45
  • SyntaxError

Answer :2322

Python Certification Exam Preparation Set 45

The meaning of positional parameter is determined by:


Options are :

  • Position (Correct)
  • Name
  • Style
  • None

Answer :Position

The operation // in python:


Options are :

  • Does Regular expression
  • Does simple division
  • Is not a valid operation
  • Returns the integral part of the quotient. (Correct)

Answer :Returns the integral part of the quotient.

Right side binding means the following expression will be evaluated:

2**4**2


Options are :

  • Random order
  • Left to Right
  • Right to Left (Correct)

Answer :Right to Left

Python Certification Exam Preparation Set 57

A keyword is a word that


Options are :

  • is the key to run the code
  • cannot be used as variable (Correct)
  • is the main subject of the code

Answer :cannot be used as variable

Select the incorrect statement:


Options are :

  • Multiplication precedes the addition
  • The ** operator uses right-sided binding
  • The right argument of the % operator cannot be zero
  • The result of the / operator is always an integer value (Correct)

Answer :The result of the / operator is always an integer value

What is the output of the following code?

print(3==3.)


Options are :

  • True (Correct)
  • False

Answer :True

Python Certification Exam Preparation Set 57

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

Print(1%2)


Options are :

  • 0
  • 1 (Correct)
  • .5
  • 2

Answer :1

It's legal, to have a variable named the same as a function's parameter.


Options are :

  • True (Correct)
  • False

Answer :True

Select the correct statements about 'None' in Python:


Options are :

  • *None is a keyword. (Correct)
  • *None can be assigned to a variable. (Correct)
  • *None can be used to compare it with a variable. (Correct)
  • None is not a keyword.

Answer :*None is a keyword. *None can be assigned to a variable. *None can be used to compare it with a variable.

Python Certification Exam Preparation Set 55

A List can be sent to a function as an argument.


Options are :

  • True (Correct)
  • False

Answer :True

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions