Python Certification Exam Preparation Set 63

What is the output of the code shown below?


Options are :

  • Error
  • 'Sanfoundry\n' (Correct)
  • 'Sanfoundry'
  • 'Sanfoundry10'

Answer :'Sanfoundry\n'

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

Is Python code compiled or interpreted?


Options are :

  • Python code is only interpreted
  • Python code is both compiled and interpreted (Correct)
  • Python code is only compiled
  • Python code is neither compiled nor interpreted

Answer :Python code is both compiled and interpreted

Which of the following is the same as math.exp(p)?


Options are :

  • math.e ** p (Correct)
  • e ** p
  • p ** e
  • p ** math.e

Answer :math.e ** p

What does os.close(f) do?


Options are :

  • terminate the process f if f is not responding
  • close the file descriptor f (Correct)
  • return an integer telling how close the file pointer is to the end of file
  • terminate the process f

Answer :close the file descriptor f

Python Certification Exam Preparation Set 30

What is the output of the snippet of code shown below?


Options are :

  • A straight line of 100 units tilted at 15 degrees from the horizontal
  • Error
  • A straight line of 100 units lying along the horizontal (Correct)
  • A straight line of 100 units tiled at 75 degrees from the horizontal

Answer :A straight line of 100 units lying along the horizontal

The function used to alter the thickness of the pen to 'x' units:


Options are :

  • turtle.girth(x)
  • turtle.thickness(x)
  • turtle.span(x)
  • turtle.width(x) (Correct)

Answer :turtle.width(x)

Which of the following is equivalent to random.randrange(3)?


Options are :

  • random.choice(range(0, 3)) (Correct)
  • range(3)
  • random.shuffle(range(3))
  • random.select(range(3))

Answer :random.choice(range(0, 3))

Python Certification Exam Preparation Set 2

What is the output of the following?


Options are :

  • [1234].
  • [1, 2, 3, 4].
  • none of the mentioned (Correct)
  • [[1], [2], [3], [4]].

Answer :none of the mentioned

Which of the following functions can help us to find the version of python that we are currently working on?


Options are :

  • sys.version()
  • sys.version (Correct)
  • sys.version(1)
  • sys.version(0)

Answer :sys.version

What is the value of x if x = math.sqrt(4)?


Options are :

  • 2.0 (Correct)
  • (2.0, -2.0)
  • (2, -2)
  • 2

Answer :2.0

Python Certification Exam Preparation Set 14

What is the output of the code shown below?


Options are :

  • Yes
  • No
  • True
  • False (Correct)

Answer :False

What is the range of values that random.random() can return?


Options are :

  • (0.0, 1.0)
  • [0.0, 1.0].
  • [0.0, 1.0) (Correct)
  • (0.0, 1.0].

Answer :[0.0, 1.0)

Which of the following is false about "from-import" form of import?


Options are :

  • The namespace of imported module becomes part of importing module
  • The syntax is: from modulename import identifier
  • The identifiers in module are accessed directly as: identifier
  • This form of import prevents name clash (Correct)

Answer :This form of import prevents name clash

Python Certification Exam Preparation Set 6

What is the output of the following?


Options are :

  • ['a', 'b', 'c', 'd'].
  • none of the mentioned (Correct)
  • ['abcd'].
  • [['a'], ['b'], ['c'], ['d']].

Answer :none of the mentioned

What is the output of the code shown below?


Options are :

  • ' ' (Correct)
  • Error
  • No output
  • Junk value

Answer :' '

What is returned by int(math.pow(3, 2))?


Options are :

  • 9 (Correct)
  • error, too many arguments
  • 6
  • error, third argument required

Answer :9

Python Certification Exam Preparation Set 20

Which type of elements are accepted by random.shuffle()?


Options are :

  • strings
  • integers
  • tuples
  • lists (Correct)

Answer :lists

What does os.getlogin() return?


Options are :

  • all of the above
  • name of the current user logged in (Correct)
  • name of the superuser
  • gets a form to login as a different user

Answer :name of the current user logged in

The code shown below will result in an error. State whether true or false.


Options are :

  • False (Correct)
  • True

Answer :False

Python Certification Exam Preparation Set 43

What is the output of the following?


Options are :

  • [34, 56].
  • error (Correct)
  • ['34', '56'].
  • 34 56

Answer :error

The process of pickling in Python includes:


Options are :

  • conversion of a datatable into a list
  • conversion of a Python object hierarchy into byte stream (Correct)
  • conversion of a byte stream into Python object hierarchy
  • conversion of a list into a datatable

Answer :conversion of a Python object hierarchy into byte stream

Which of the codes shown below will result in an error?
Given that:


Options are :

  • >>> pickle.dumps(object, 3, True) (Correct)
  • >>> pickle.dumps(object, 3)
  • >>> pickle.dumps(object)
  • >>> pickle.dumps('a', 2)

Answer :>>> pickle.dumps(object, 3, True)

Python Certification Exam Preparation Set 7

Which of the following functions is not defined under the sys module?


Options are :

  • sys.readline (Correct)
  • sys.platform
  • sys.path
  • sys.argv

Answer :sys.readline

What is the default base used when math.log(x) is found?


Options are :

  • none of the mentioned
  • 10
  • 2
  • e (Correct)

Answer :e

The output of both of the print statements is the same. State whether true or false.


Options are :

  • True
  • False (Correct)

Answer :False

Python Certification Exam Preparation Set 58

Which of the following will not be returned by random.choice("1 ,")?


Options are :

  • none of the mentioned (Correct)
  • (space)
  • 1
  • ,

Answer :none of the mentioned

Pick the correct statement regarding pickle and marshal modules.


Options are :

  • The pickle module keeps track of the objects that have already been sterilized whereas the marshal module does not do this (Correct)
  • The pickle module supports primarily .pyc files whereas marshal module is used to sterilize Python objects
  • The pickle module cannot be used to sterilize user defined classes and their instances whereas marshal module can be used to perform this task
  • The format of sterilization of the pickle module is not guaranteed to be supported across all versions of Python. The marshal module sterilization is compatible across all the versions of Python

Answer :The pickle module keeps track of the objects that have already been sterilized whereas the marshal module does not do this

What does os.name contain?


Options are :

  • the address of the module os
  • none of the mentioned
  • error, it should've been os.name()
  • the name of the operating system dependent module imported (Correct)

Answer :the name of the operating system dependent module imported

Python Certification Exam Preparation Set 16

What is the output of the following line of code, if the sys module has already been imported?


Options are :

  • error
  • helloworld
  • hello world11 (Correct)
  • hello world10

Answer :hello world11

What is the output of the following?


Options are :

  • ['abcd'].
  • [['a'], ['b'], ['c'], ['d']].
  • ['a', 'b', 'c', 'd'].
  • none of the mentioned (Correct)

Answer :none of the mentioned

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions