PCAP-31-03
Free trial
Verified
Question 1
What is true about Python packages? (Choose two.)
- A: a code designed to initialize a package’s state should be placed inside a file named init.py
- B: a package’s contents can be stored and distributed as an mp3 file
- C: __pycache__ is a folder that stores semi-compiled Python modules
- D: the sys.path variable is a list of strings
Question 2
What is true about the following snippet? (Choose two.)
- A: the string what a pity will be seen
- B: the string it's nice to see you will be seen
- C: the code will raise an unhandled exception
- D: the string I feel fine will be seen
Question 3
Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)
- A:
- B:
- C:
- D:
Question 4
Which of the following statements are true? (Choose two.)
- A: II in ASCII stands for Information Interchange
- B: a code point is a number assigned to a given character
- C: ASCII is synonymous with UTF-8
- D: \e is an escape sequence used to mark the end of lines
Question 5
Assuming that the following inheritance set is in force, which of the following classes are declared properly? (Choose two.)
- A: class Class_2(B,D): pass
- B: class Class_1(C,D): pass
- C: class Class_3(A,C): pass
- D: class Class_4(D,A): pass
Question 6
Assuming that the code below has been executed successfully, which of the following expressions evaluate to True? (Choose two.)
- A: 'var' in Object.__dict__
- B: 'var' in Class.__dict__
- C: len(Object.__dict__) == 1
- D: 'prop' in Class.__dict__
Question 7
What is the expected behavior of the following code?
- A: it outputs -2
- B: it outputs 2.0
- C: it outputs 0.0
- D: the code is erroneus and it will not execute
Question 8
A Python module named pymod.py contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
- A: from pymod import * pymod.pyfun()
- B: import pyfun from pymod pyfun()
- C: import pymod pymod.pyfun()
- D: from pymod import pyfun pyfun()
Question 9
Which of the following expressions evaluate to True? (Choose two.)
- A: 'abc'.upper() < 'abc'
- B: '1'+'2' * 2 != '12'
- C: 3 * 'a' < 'a' * 2
- D: 11 == '011'
Question 10
Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Choose two.)
string = 'SKY'[::-1]
string = string[-1]
- A: len(string) == 1
- B: string[0] == 'Y'
- C: string[0] == string[-1]
- D: string is None
Question 11
What is true about the bases property?
- A: there is no such property
- B: it is accessible inside a class and an object
- C: it is accessible inside a class
- D: it is accessible inside an object
Question 12
Which of the following statements are true? (Choose two.)
- A: if invoking open() fails, the value None is returned
- B: open() is a function which returns an int that represents a physical file handle
- C: the second open() argument is optional
- D: instd, outstd, errstd are the names of pre-opened streams
Question 13
What is the expected behavior of the following code?
- A: it outputs error
- B: it outputs
- C: the code is erroneous and it will not execute
- D: it outputs list assignment index out of range
Question 14
What is the expected output of the following code if there is no file named non_existing_file inside the working directory?
- A: 1 2 4
- B: 2 4
- C: 1 2 3 4
- D: 1 3
Question 15
What is the expected behavior of the following code?
- A: it outputs 2
- B: it raises an exception
- C: it outputs 1
- D: it outputs 0
Question 16
Which of the following expressions evaluate to True? (Choose two.)
- A: ord("0") - ord("9") == 10
- B: len("''") == 2
- C: chr(ord('z') - 1) == 'y'
- D: len(''1234'') == 4
Question 17
Which of the following expressions evaluate to True? (Choose two.)
- A: 'xYz'.lower() > 'XY'
- B: '8'+'8' ! = 2 * '8'
- C: float ('3.14') == str('3.' + '14')
- D: 121 + 1 == int('1' + 2 * '2')
Question 18
What is the expected behavior of the following code?
- A: it outputs 3
- B: it outputs 'None'
- C: it outputs 0
- D: it raises an exception
Question 19
What is the expected behavior of the following code?
the_list = "alpha;beta;gamma".split(";")
the_string = ''.join(the_list)
print(the_string.isalpha())
- A: it outputs True
- B: it outputs False
- C: it outputs nothing
- D: it raises an exception
Question 20
Which of the following invocations are valid? (Choose two.)
- A: sort("python")
- B: "python".find("")
- C: "python".sort()
- D: sorted("python")
Question 21
Which of the following expressions evaluate to True? (Choose two.)
- A: 'in' in 'in'
- B: 'in' in 'Thames'
- C: 'in not' in 'not'
- D: 't'.upper() in 'Thames'
Question 22
Assuming that the snippet below has been executed successfully, which of the following expressions will evaluate to True? (Choose two.) string = 'python'[::2] string = string[-1] + string[-2]
- A: len(string) == 3
- B: string[0] == 'o'
- C: string[0] == string[-1]
- D: string is None
That’s the end of your free questions
You’ve reached the preview limit for PCAP-31-03Consider upgrading to gain full access!
Free preview mode
Enjoy the free questions and consider upgrading to gain full access!