PCAPga : Certified Associate in Python Programming : Part 06

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

    PCAP Certified Associate in Python Programming Part 06 Q01 086
    PCAP Certified Associate in Python Programming Part 06 Q01 086
    • isinstance (obj_b,A)
    • A.VarA == 1
    • obj_a is obj_aa
    • B.VarA == 1
  2. Assuming that the code below has been executed successfully, which of the expressions evaluate to True? (Choose two.)

    PCAP Certified Associate in Python Programming Part 06 Q02 087
    PCAP Certified Associate in Python Programming Part 06 Q02 087
    • len(Class.__dict__) == 1
    • ‘data’ in Class.__dict__
    • ‘var’ in Class.__dict__
    • ‘data’ in Object.__dict__
  3. A property that stores information about a given class’s super-classes is named:

    • __upper__
    • __super__
    • __ancestors__
    • __bases__

    Explanation:

    Reference: https://www.python-course.eu/python3_inheritance.php

  4. Which of the following lines of code will work flawlessly when put independently inside the add_new() method in order to make the snippet’s output equal to [0, 1, 2]? (Choose two.)

    PCAP Certified Associate in Python Programming Part 06 Q04 088
    PCAP Certified Associate in Python Programming Part 06 Q04 088
    • self.queue.append(self.get_last() + 1)
    • self.queue.append(get_last() + 1)
    • self.queue.append(self.queue[-1] + 1)
    • queue.append(self.get_last() + 1)
  5. What is the expected output of the following code?

    PCAP Certified Associate in Python Programming Part 06 Q05 089
    PCAP Certified Associate in Python Programming Part 06 Q05 089
    • a
    • c
    • an exception is raised
    • b
    Explanation:
    PCAP Certified Associate in Python Programming Part 06 Q05 090
    PCAP Certified Associate in Python Programming Part 06 Q05 090
  6. What is the expected output of the following code if there is no file named non_existing_file inside the working directory?

    PCAP Certified Associate in Python Programming Part 06 Q06 091
    PCAP Certified Associate in Python Programming Part 06 Q06 091
    • 1 2 4
    • 1 2 3 4
    • 2 4
    • 1 3
  7. What is the expected output of the following code if the file named existing_text_file is a non-zero length text file located inside the working directory?

    PCAP Certified Associate in Python Programming Part 06 Q07 092
    PCAP Certified Associate in Python Programming Part 06 Q07 092
    • the length of the first line from the file
    • -1
    • the number of lines contained inside the file
    • the length of the last line from the file
  8. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 06 Q08 093
    PCAP Certified Associate in Python Programming Part 06 Q08 093
    • it outputs [1, 3]
    • the code is erroneous and it will not execute
    • it outputs [3, 1]
    • it outputs [4, 2, 0]
    Explanation:
    PCAP Certified Associate in Python Programming Part 06 Q08 094
    PCAP Certified Associate in Python Programming Part 06 Q08 094
  9. Assuming that the following code has been executed successfully, which of the expressions evaluate to True? (Choose two.)

    PCAP Certified Associate in Python Programming Part 06 Q09 095
    PCAP Certified Associate in Python Programming Part 06 Q09 095
    • b() == 4
    • a != b
    • a is not None
    • a() == 4
  10. What is the expected output of the following code?

    PCAP Certified Associate in Python Programming Part 06 Q10 096
    PCAP Certified Associate in Python Programming Part 06 Q10 096
    • 3
    • 5
    • 4
    • an exception is raised
    Explanation:
    PCAP Certified Associate in Python Programming Part 06 Q10 097
    PCAP Certified Associate in Python Programming Part 06 Q10 097
  11. Which of the following lambda definitions are correct? (Choose two.)

    • lambda x,y: (x,y)
    • lambda x,y: return x//y – x%y
    • lambda x,y: x//y – x%y
    • lambda x,y = x//y – x%y
  12. Which of the following statements are true? (Choose two.)

    • if invoking open () fails, an exception is raised
    • open () requires a second argument
    • open () is a function which returns an object that represents a physical file
    • instd, outstd. errstd are the names of pre-opened streams
  13. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 06 Q13 098
    PCAP Certified Associate in Python Programming Part 06 Q13 098
    • the code is erroneous and it will not execute
    • it outputs 1
    • it outputs -1
    • it outputs 0
    Explanation:
    PCAP Certified Associate in Python Programming Part 06 Q13 099
    PCAP Certified Associate in Python Programming Part 06 Q13 099
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments