PCAP : Certified Associate in Python Programming : Part 05

  1. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q01 067
    PCAP Certified Associate in Python Programming Part 05 Q01 067
    • it outputs 3
    • the code is erroneous and it will not execute
    • it outputs 1
    • it outputs 2

    Explanation:

    PCAP Certified Associate in Python Programming Part 05 Q01 068
    PCAP Certified Associate in Python Programming Part 05 Q01 068
  2. Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)

    • PCAP Certified Associate in Python Programming Part 05 Q02 063
      PCAP Certified Associate in Python Programming Part 05 Q02 063
    • PCAP Certified Associate in Python Programming Part 05 Q02 064
      PCAP Certified Associate in Python Programming Part 05 Q02 064
    • PCAP Certified Associate in Python Programming Part 05 Q02 065
      PCAP Certified Associate in Python Programming Part 05 Q02 065
    • PCAP Certified Associate in Python Programming Part 05 Q02 066
      PCAP Certified Associate in Python Programming Part 05 Q02 066
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q02 067
    PCAP Certified Associate in Python Programming Part 05 Q02 067
  3. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q03 068
    PCAP Certified Associate in Python Programming Part 05 Q03 068
    • it outputs error
    • it outputs <class ‘IndexError’>
    • it outputs list assignment index out of range
    • the code is erroneous and it will not execute
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q03 069
    PCAP Certified Associate in Python Programming Part 05 Q03 069
  4. What is true about the following snippet? (Choose two.)

    PCAP Certified Associate in Python Programming Part 05 Q04 070
    PCAP Certified Associate in Python Programming Part 05 Q04 070
    • the string it’s nice to see you will be seen
    • the string I feel fine will be seen
    • the code will raise an unhandled exception
    • the string what a pity will be seen
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q04 071
    PCAP Certified Associate in Python Programming Part 05 Q04 071
  5. Which of the following expressions evaluate to True? (Choose two.)

    • ord(“Z”) - ord(“z”) == ord(“0”)
    • chr(ord(‘A’) +1) == ‘B’
    • len(‘\’’) == 1
    • len(“““
      
      ”””) == 0
  6. Which of the following invocations are valid? (Choose two.)

    • “python”.sort()
    • sorted(“python”)
    • rfind(“python”,“r”)
    • “python”.index(“th”)
  7. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q07 072
    PCAP Certified Associate in Python Programming Part 05 Q07 072
    • it raises an exception
    • it outputs 0
    • it outputs 3
    • it outputs ‘None’
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q07 073
    PCAP Certified Associate in Python Programming Part 05 Q07 073
  8. Which of the following statements are true? (Choose two.)

    • II in ACII stands for Information Interchange
    • a code point is a number assigned to a given character
    • ACII is synonymous with UTF-8
    • \e is an escape sequence used to mark the end of lines
    Explanation:
    Reference: https://www.tutorialsteacher.com/python/ascii-method
  9. Which of the following expressions evaluate to True? (Choose two.)

    • str(1-1) in ‘123456789’[:2]
    • ‘dcb’ not in ‘abcde’[::-1]
    • ‘phd’ in ‘aplpha’
    • ‘Truenot inFalse’
  10. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q10 074
    PCAP Certified Associate in Python Programming Part 05 Q10 074
    • it raises an exception
    • it outputs True
    • it outputs False
    • it outputs nothing
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q10 075
    PCAP Certified Associate in Python Programming Part 05 Q10 075
  11. Which of the following expressions evaluate to True? (Choose two.)

    • 121 + 1 != ‘1’ + 2 * ‘2’
    • ‘1’ + ‘1’ + ‘1’ < ‘1’ *3’
    • ‘AbC’.lower() < ‘AB’
    • ‘3.14’ != str(3.1415)
  12. Assuming that the snippet below has been executed successfully, which of the following expressions evaluate to True? (Choose two.)

    string = ‘python’[::2]
    string = string[-1] + string[-2]

    • string[0] == ‘o’
    • string is None
    • len(string) == 3
    • string[0] == string [-1]
  13. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q13 076
    PCAP Certified Associate in Python Programming Part 05 Q13 076
    • it outputs 0
    • it outputs 1
    • it raises an exception
    • it outputs 2
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q13 077
    PCAP Certified Associate in Python Programming Part 05 Q13 077
  14. Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)

    PCAP Certified Associate in Python Programming Part 05 Q14 078
    PCAP Certified Associate in Python Programming Part 05 Q14 078
    • class Class_4(D,A): pass
    • class Class_3(A,C): pass
    • class Class_2(B,D): pass
    • class Class_1(C,D): pass
  15. What is the expected output of the following snippet?

    PCAP Certified Associate in Python Programming Part 05 Q15 079
    PCAP Certified Associate in Python Programming Part 05 Q15 079
    • True upper
    • True lower
    • False upper
    • False lower
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q15 080
    PCAP Certified Associate in Python Programming Part 05 Q15 080
  16. Assuming that the code below has been placed inside a file named code.py and executed successfully, which of the following expressions evaluate to True? (Choose two.)

    PCAP Certified Associate in Python Programming Part 05 Q16 081
    PCAP Certified Associate in Python Programming Part 05 Q16 081
    • len(ClassB.__bases__) ==2
    • ClassA.__module__ == ‘__main__’
    • __name__ == ‘code.py’
    • str(Object) == ‘Object’
  17. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q17 082
    PCAP Certified Associate in Python Programming Part 05 Q17 082
    • it outputs 1
    • it outputs 3
    • it outputs 6
    • it raises an exception
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q17 083
    PCAP Certified Associate in Python Programming Part 05 Q17 083
  18. What is the expected behavior of the following code?

    PCAP Certified Associate in Python Programming Part 05 Q18 084
    PCAP Certified Associate in Python Programming Part 05 Q18 084
    • it outputs 0
    • it raises an exception
    • it outputs 1
    • it outputs 2
    Explanation:
    PCAP Certified Associate in Python Programming Part 05 Q18 085
    PCAP Certified Associate in Python Programming Part 05 Q18 085
  19. What is true about Object-Oriented Programming in Python? (Choose two.)

    • each object of the same class can have a different set of methods
    • a subclass is usually more specialized than its superclass
    • if a real-life object can be described with a set of adjectives, they may reflect a Python object method
    • the same class can be used many times to build a number of objects
    Explanation:
    Reference: https://www.whitman.edu/mathematics/java_tutorial/java/javaOO/subclasses.html
  20. What is true about Python class constructors? (Choose two.)

    • there can be more than one constructor in a Python class
    • the constructor must return a value other than None
    • the constructor is a method named __init__
    • the constructor must have at least one parameter
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments