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

What is "Hello".replace("l", "e")?


Options are :

  • Heeeo
  • Heelo
  • Heleo
  • None

Answer :Heeeo

Python Certification Exam Preparation Set 49

To retrieve the character at index 3 from string s="Hello" what command do we execute (multiple answers allowed)?


Options are :

  • s[]
  • s.getitem(3)
  • s.__getitem__(3)
  • s.getItem(3)

Answer :s.__getitem__(3)

To return the length of string s what command do we execute?


Options are :

  • s.__len__()
  • len(s)
  • size(s)
  • s.size()

Answer :s.__len__()

If a class defines the __str__(self) method, for an object obj for the class, you can use which command to invoke the __str__ method.


Options are :

  • obj.__str__()
  • str(obj)
  • print obj
  • all of the mentioned

Answer :all of the mentioned

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

To check whether string s1 contains another string s2, use ________


Options are :

  • s1.__contains__(s2)
  • s2 in s1
  • s1.contains(s2)
  • si.in(s2)

Answer :s1.__contains__(s2)

Suppose i is 5 and j is 4, i + j is same as ________


Options are :

  • i.__add(j)
  • i.__add__(j)
  • i.__Add(j)
  • i.__ADD(j)

Answer :i.__add__(j)

What will be the output of the following Python code?


Options are :

  • True False
  • True True
  • False True
  • False False

Answer :False True

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

What will be the output of the following Python code?


Options are :

  • Peter Pan
  • John Pan
  • Peter Smith
  • John Smith

Answer :John Pan

What function do you use to read a string?


Options are :

  • input("Enter a string")
  • eval(input("Enter a string"))
  • enter("Enter a string")
  • eval(enter("Enter a string"))

Answer :input("Enter a string")

Suppose x is 345.3546, what is format(x, "10.3f") (_ indicates space).


Options are :

  • __345.355
  • ___345.355
  • ____345.355
  • _____345.354

Answer :___345.355

Python Certification Exam Preparation Set 5

What will be the output of the following Python code?


Options are :

  • abc def
  • ABC DEF
  • Abc def
  • Abc Def

Answer :Abc def

What will be the output of the following Python code?


Options are :

  • abc. def
  • ABC. DEF
  • Abc. def
  • Abc. Def

Answer :Abc. def

What will be the output of the following Python code?


Options are :

  • cd
  • abcdef
  • error
  • none of the mentioned

Answer :error

Python Certification Exam Preparation Set 29

What will be the output of the following Python code?


Options are :

  • cd
  • abcdef
  • error
  • none of the mentioned

Answer :abcdef

What will be the output of the following Python code?


Options are :

  • * abcdef *
  • * abcdef *
  • *abcdef *
  • * abcdef*

Answer :* abcdef *

What will be the output of the following Python code?


Options are :

  • * abcdef *
  • * abcdef *
  • *abcdef *
  • * abcdef*

Answer :* abcdef*

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

What will be the output of the following Python code?


Options are :

  • * abcde *
  • * abcde *
  • *abcde *
  • * abcde*

Answer :*abcde *

What will be the output of the following Python code?


Options are :

  • 1abcdef
  • abcdef1
  • abcdef
  • error

Answer :error

What will be the output of the following Python code?


Options are :

  • 1abcdef
  • abcdef1
  • abcdef
  • error

Answer :1abcdef

Python Certification Exam Preparation Set 16

What will be the output of the following Python code?


Options are :

  • 12abcdef12
  • abcdef1212
  • 1212abcdef
  • error

Answer :error

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • error
  • none of the mentioned

Answer :2

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • 1
  • none of the mentioned

Answer :2

Python Certification Exam Preparation Set 53

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • 1
  • none of the mentioned

Answer :1

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • 1
  • error

Answer :2

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • 1
  • error

Answer :0

", $fileContentFew); $title = explode("

Python Certification Exam Preparation Set 63

What will be the output of the following Python code?


Options are :

  • 2
  • 0
  • 1
  • error

Answer :0

What will be the output of the following Python code?


Options are :

  • abc
  • 'abc'
  • b'abc'
  • h'abc'

Answer :b'abc'

What is the default value of encoding in encode()?


Options are :

  • ascii
  • qwerty
  • utf-8
  • utf-16

Answer :utf-8

Python Certification Exam Preparation Set 3

What will be the output of the following Python code?


Options are :

  • 1
  • True
  • 3
  • 2

Answer :True

What will be the output of the following Python code?


Options are :

  • 0
  • 1
  • True
  • False

Answer :False

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions