What is the expected output of the following code?
import sys
import math
b1 = type(dir(math)) is list
b2 = type(sys.path) is list
print(b1 and b2)
ANone
BTrue
C0
DFalse
Assuming that the code below has been executed successfully, which of the following expressions will always evaluate to True? (Choose two.) import random v1 = random.random() v2 = random.random()
Alen(random.sample([1,2,3],1)) > 2
Bv1 == v2
Crandom.choice([1,2,3]) > 0
Dv1>1
What is the expected behavior of the following code?
Athe code is erroneous and it will not execute
Bit outputs 1
Cit outputs 2
Dit outputs 0
Which of the following expressions evaluate to True? (Choose two.)
A'xYz'.lower() > 'XY'
B'8'+'8' ! = 2 * '8'
Cfloat ('3.14') == str('3.' + '14')
D121 + 1 == int('1' + 2 * '2')
Which of the following invocations are valid? (Choose two.)
Asort("python")
B"python".find("")
C"python".sort()
Dsorted("python")
What is true about Python packages? (Choose two.)
Aa code designed to initialize a package’s state should be placed inside a file named init.py
Ba package’s contents can be stored and distributed as an mp3 file
Cpycache is a folder that stores semi-compiled Python modules
Dthe sys.path variable is a list of strings
Which of the following snippets will execute without raising any unhandled exceptions? (Choose two.)
A
B
C
D
Which of the following expressions evaluate to True? (Choose two.)
Aord("0") - ord("9") == 10
Blen("''") == 2
Cchr(ord('z') - 1) == 'y'
Dlen(''1234'') == 4
What is the expected behavior of the following code?
x =3 % 1
y = 1 if x > 0 else 0
print(y)
Athe code is erroneus and it will not execute
Bit outputs 1
Cit outputs 0
Dit outputs -1
What is the expected output of the following code?
Aan exception is raised
B1
C0
D-1
Assuming that the following code has been executed successfully, select the expressions which evaluate to True (Choose two.)
Aa is not None
Ba() == 4
Ca != b
Db() == 4
Which one of the platform module functions should be used to determine the underlying platform name?
Aplatform.processor()
Bplatform.uname()
Cplatform.python_version()
Dplatform.platform()
With regards to the directory structure below, select the proper forms of the directives in order to import module_c. (Choose two.)
Afrom pypack.upper.lower import module_c
Bimport pypack.upper.lower.module_c
Cimport upper.module_c
Dimport upper.lower.module_c
What is true about the following snippet? (Choose two.)
Athe string what a pity will be seen
Bthe string it's nice to see you will be seen
Cthe code will raise an unhandled exception
Dthe string I feel fine will be seen
What is the expected behavior of the following code?
Ait outputs error
Bit outputs
Cthe code is erroneous and it will not execute
Dit outputs list assignment index out of range
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]
Alen(string) == 3
Bstring[0] == 'o'
Cstring[0] == string[-1]
Dstring is None
What is the expected behavior of the following code?
Ait outputs 3
Bit outputs 'None'
Cit outputs 0
Dit raises an exception
Which of the following statements are true? (Choose two.)
Aan escape sequence can be recognized by the / sign put in front of it
BASCII is a subset of UNICODE
CII in ASCII stands for Internal Information
Da code point is a number assigned to a given character
What is the expected behavior of the following code?
Ait outputs 1
Bit outputs 0
Cit raises an exception
Dit outputs 2
What is the expected behavior of the following code?
Ait raises an exception
Bit outputs 2
Cit outputs 0
Dit outputs 1
What is the expected behavior of the following code?
my_list = [i for i in range(5)]
m = [my_list[i] for i in range(4, 0, -1) if my_list[i] % 2 != 0] print(m)
Athe code is erroneus and it will not execute
Bit outputs [4, 2, 0]
Cit outputs [3, 1]
Dit outputs [1, 3]
What is the expected behavior of the following code?
Ait outputs 3
Bit outputs 1
Cit outputs 2
Dthe code is erroneous and it will not execute
Which of the following statements are true? (Choose two.)
Aif invoking open() fails, an exception is raised
Binstd, outstd, errstd are the names of pre-opened streams
Copen() requires a second argument
Dopen() is a function which returns an object that represents a physical file
A Python package named pypack includes a module named pymod.py which contains a function named pyfun().
Which of the following snippets will let you invoke the function? (Choose two.)
What is the expected behavior of the following code?
the_list = "alpha;beta;gamma".split(";")
the_string = ''.join(the_list)
print(the_string.isalpha())