Python Certification Exam Preparation Set 44

What will be the output of the following Python code?


Options are :

  • 8
  • 256 (Correct)
  • 32
  • 64

Answer :256

What will be the output of the following Python code?


Options are :

  • ['a', 'B']
  • ['a']
  • ['0', '3B6'] (Correct)
  • Error

Answer :['0', '3B6']

The difference between the functions re.sub and re.subn is that re.sub returns a _______________ whereas re.subn returns a __________________


Options are :

  • string, tuple (Correct)
  • tuple, list
  • string, list
  • list, tuple

Answer :string, tuple

Python Certification Exam Preparation Set 54

Which module in Python supports regular expressions?


Options are :

  • regex
  • pyregex
  • none
  • re (Correct)

Answer :re

The expression a{5} will match _____________ characters with the previous regular expression.


Options are :

  • 5 or more
  • 5 or less
  • exactly 5 (Correct)
  • exactly 4

Answer :exactly 5

What will be the output of the following Python code?


Options are :

  • ('we', 'are', 'humans')
  • (we, are, humans)
  • 'we are humans' (Correct)
  • ('we', 'humans')

Answer :'we are humans'

Python Certification Exam Preparation Set 23

The output of the following two Python codes are the same.


Options are :

  • True (Correct)
  • False

Answer :True

Choose the function whose output can be: <_sre.SRE_Match object; span=(4, 8), match='aaaa'>


Options are :

  • >>> re.search('aaaa', "alohaaaa", 0) (Correct)
  • >>> re.search('aaa', "alohaaa", 0)
  • >>> re.match('aaa', "alohaaa", 0)
  • >>> re.match('aaaa', "alohaaaa", 0)

Answer :>>> re.search('aaaa', "alohaaaa", 0)

Which of the following creates a pattern object?


Options are :

  • re.create(str)
  • re.compile(str) (Correct)
  • re.assemble(str)
  • re.regex(str)

Answer :re.compile(str)

Python Certification Exam Preparation Set 36

Which of the codes shown below results in a match?


Options are :

  • re.match('George(?=Washington)', 'GeorgeWashington') (Correct)
  • re.match('George(?=Washington)', 'Georgewashington')
  • re.match('George(?=Washington)', 'George Washington')
  • re.match('George(?=Washington)', 'George')

Answer :re.match('George(?=Washington)', 'GeorgeWashington')

Which of the following pattern matching modifiers permits whitespace and comments inside the regular expression?


Options are :

  • re.X (Correct)
  • re.S
  • re.L
  • re.U

Answer :re.X

What will be the output of the following Python code?


Options are :

  • 'good evening' (Correct)
  • 'evening'
  • 'morning'
  • 'good'

Answer :'good evening'

Python Certification Exam Preparation Set 45

The function of re.search is __________


Options are :

  • Matches a pattern from any part of a string (Correct)
  • Matches a pattern at the end of the string
  • Matches a pattern at the start of the string
  • Such a function does not exist

Answer :Matches a pattern from any part of a string

What will be the output of the following Python code?

a)

b)

c)

d)


Options are :

  • c
  • d
  • b
  • a (Correct)

Answer :a

What will be the output of the following Python code?


Options are :

  • ('horses', 'are', 'fast')
  • 'horses are fast'
  • 'are' (Correct)
  • {'animal': 'horses', 'verb': 'are', 'adjective': 'fast'}

Answer :'are'

Python Certification Exam Preparation Set 18

What will be the output of the following Python code?


Options are :

  • 'we are humans'
  • 'are'
  • 'humans' (Correct)
  • 'we'

Answer :'humans'

What would you say, either the given statement is Python 2 or Python 3? {print "ARK"}


Options are :

  • Python 2 (Correct)
  • Both
  • Python 3
  • None

Answer :Python 2

Python Certification Exam Preparation Set 32

What is the purpose of PYTHONPATH environment variable?


Options are :

  • This variable tells the Python interpreter where to locate the module files imported into a program. (Correct)
  • It is an alternative module search path.
  • It contains the path of an initialization file containing Python source code.
  • It is used in Windows to instruct Python to find the first case-insensitive match in an import statement.

Answer :This variable tells the Python interpreter where to locate the module files imported into a program.

Python Programming Language is derived from


Options are :

  • Unix shell
  • C++
  • All (Correct)
  • C

Answer :All

Is python a case sensitive language?


Options are :

  • NO
  • YES (Correct)

Answer :YES

Python Certification Exam Preparation Set 53

Who create Python?


Options are :

  • Guido van Rossum (Correct)
  • Rasmus Lerdorf
  • James Gosling
  • Dennis Ritchie

Answer :Guido van Rossum

Output of 1/2 in Python2 and Python3, respectively, is


Options are :

  • 0.5, 0
  • 0, 0
  • 0, 0.5 (Correct)
  • 0.5, 0.5

Answer :0, 0.5

What is the purpose of PYTHONCASEOK environment variable?


Options are :

  • It is an alternative module search path.
  • It contains the path of an initialization file containing Python source code.
  • It is used in Windows to instruct Python to find the first case-insensitive match in an import statement. (Correct)
  • This variable tells the Python interpreter where to locate the module files imported into a program.

Answer :It is used in Windows to instruct Python to find the first case-insensitive match in an import statement.

Python Certification Exam Preparation Set 44

Python runs on


Options are :

  • Linux (Ubuntu, Kubuntu, Fedora, Mint etc. )
  • Windows
  • All of the Above. (Correct)
  • Mac

Answer :All of the Above.

raw_input() and intput() are in which versions of Python, speaking respectively


Options are :

  • They are not present in both verions.
  • Python3, Python2
  • Python2, Python3 (Correct)
  • They are in both versions.

Answer :Python2, Python3

Is "lambda" a reserved keyword in Python ?


Options are :

  • YES (Correct)
  • NO

Answer :YES

Python Certification Exam Preparation Set 5

To donate string literals python supports ____ quotes


Options are :

  • Tripple (''' or """)
  • Single (')
  • Double (")
  • All (Correct)

Answer :All

Comments in Python begin with


Options are :

  • ;
  • $
  • # (Correct)
  • //

Answer :#

What is the purpose of PYTHONHOME environment variable?


Options are :

  • This variable tells the Python interpreter where to locate the module files imported into a program.
  • It is an alternative module search path. (Correct)
  • It contains the path of an initialization file containing Python source code.
  • It is used in Windows to instruct Python to find the first case-insensitive match in an import statement.

Answer :It is an alternative module search path.

Python Certification Exam Preparation Set 4

Python Programming Language is


Options are :

  • Interactive
  • All (Correct)
  • Object-Oriented
  • Interpreted

Answer :All

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions