Certified Associate in Python Programming v1.0 (PCAP)

Page:    1 / 10   
Total 141 questions

What is the expected output of the following code?


  • A. 21
  • B. 12
  • C. 3
  • D. none


Answer : C

A method for passing the arguments used by the following snippet is called:


  • A. sequential
  • B. named
  • C. positional
  • D. keyword


Answer : C

What is the expected behavior of the following code?



It will -

  • A. print 2 1
  • B. print 1 2
  • C. cause a runtime exception
  • D. print <generator object f at (some hex digits)>


Answer : B

Explanation:


What is the expected output of the following code?


  • A. 2
  • B. The code will cause a runtime exception
  • C. 1
  • D. 3


Answer : D

What is the expected behavior of the following code?


It will:

  • A. print 0
  • B. cause a runtime exception
  • C. prints 3
  • D. print an empty line


Answer : B

If any of a classג€™s components has a name that starts with two underscores (___), then:

  • A. the class componentג€™s name will be mangled
  • B. the class component has to be an instance variable
  • C. the class component has to be a class variable
  • D. the class component has to be a method


Answer : A

Reference:
https://hackernoon.com/understanding-the-underscore-of-python-309d1a029edc

If you need to serve two different exceptions called Ex1 and Ex2 in one except branch, you can write:

  • A. except Ex1 Ex2:
  • B. except (ex1, Ex2):
  • C. except Ex1, Ex2:
  • D. except Ex1+Ex2:


Answer : B

Reference:
https://www.programiz.com/python-programming/exception-handling

A function called issubclass (c1, c2) is able to check if:

  • A. c1 and c2 are both subclasses of the same superclass
  • B. c2 is a subclass of c1
  • C. c1 is a subclass of c2
  • D. c1 and c2 are not subclasses of the same superclass


Answer : C

Reference:
https://www.oreilly.com/library/view/python-in-a/9781491913833/ch04.html

A class constructor (Choose two.)

  • A. can return a value
  • B. cannot be invoked directly from inside the class
  • C. can be invoked directly from any of the subclasses
  • D. can be invoked directly from any of the superclasses


Answer : BC

The following class definition is given. We want the show () method to invoke the get () method, and then output the value the get () method returns. Which of the invocations should be used instead of XXX?


  • A. print (get(self))
  • B. print (self.get())
  • C. print (get())
  • D. print (self.get (val))


Answer : B

If S is a stream open for reading, what do you expect from the following invocation?


  • A. one line of the file will be read and stored in the string called C
  • B. the whole file content will be read and stored in the string called C
  • C. one character will be read and stored in the string called C
  • D. one disk sector (512 bytes) will be read and stored in the string called C


Answer : B

You are going to read 16 bytes from a binary file into a bytearray called data. Which lines would you use? (Choose two.)

  • A. data = bytearray (16) bf.readinto (data)
  • B. data = binfile.read (bytearray (16))
  • C. bf. readinto (data = bytearray (16))
  • D. data = bytearray (binfile.read (16))


Answer : CD

Reference:
https://www.devdungeon.com/content/working-binary-data-python

What is the expected output of the following snippet?


  • A. True False
  • B. True True
  • C. False False
  • D. False True


Answer : A

Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Choose two.)


  • A. v1 >= 1
  • B. v1 == v2
  • C. len(random.sample([1,2,3],2)) > 2
  • D. random.choice([1,2,3]) >=1


Answer : AD

Which one of the platform module functions should be used to determine the underlying platform name?

  • A. platform.python_version()
  • B. platform.processor()
  • C. platform.platform()
  • D. platform.uname()


Answer : C

Page:    1 / 10   
Total 141 questions