-
How many stars (*) will the following snippet send to the console?
i = 0
while i <= 3 :
i += 2
print("+")
-
After execution of the following snippet, the sum of the all vals
elements will equal to:
vals = [0, 1, 2]
vals.insert(0, 1)
del vals[1]
-
How many hashes(#
) will the following snippet send to the console?
for i in range(1):
print("#")
else:
print("#")
-
How many hashes(#
) will the following snippet send to the console?
var = 0
while var < 6:
var += 1
if var % 2 == 0:
continue
print("#")
-
What is the output of the following snippet?
my_list = [3, 1, -2]
print(my_list[my_list(-1)])
-
How many stars(#
) will the following snippet send to the console?
var = 0
while i <= 5:
i += 1
if vi % 2 == 0:
break
print("*")
-
What is the output of the following snippet?
my_list = [1, 2, 3, 4]
print(my_list[-3:-2])
-
How many hashes(#
) will the following snippet send to the console?
var = 1
while var < 10:
print("#")
var = var << 1
-
What is the output of the following snippet?
my_list_1 = [1, 2, 3]
my_list_2 = []
for v in my_list_1:
my_list_2.insert(0, v)
print(my_list_2)
[1, 2, 3]
[3, 2, 1]
[3, 3, 3]
[1, 1, 1]
-
Take a look at the snippet, and choose the true statements: (Select two answer)
nums = [1, 2, 3]
vals = nums
del vals[1:2]
nums
is longer than vals
nums
and vals
are of the same length
nums
and vals
refer to the same list
nums
is replicated and assigned to vals
-
What is the output of the following snippet?
my_list = [[0, 1, 2, 3] for i in rage(2)]
print(my_list[2][0])
1
2
0
- the snippet will cause a runtime error
-
What value will be assigned to the x
variable?
z = 10
y = 0
x = y < z and z > y or y > z and z < y
-
Which of the following sentences are true? (Select two answers)
nums = [1, 2, 3]
vals = nums[-1:-2]
nums
and vals
are two different lists
- vals is longer than nums
- nums and vals are of the same length
nums
is longer than vals
-
What is the output of the following snippet?
a = 1
b = 0
c = a & b
d = a | be = a ^ b
print(c + d + e)
-
What is the output of the following snippet?
my_list = [1, 2, 3]
for v in range(len(my_list)):
my_list.insert(1, my_list[v])
print(my_list)
[1, 2, 3, 1, 2, 3]
[1, 2, 3, 3, 2, 1]
[1, 1, 1, 1, 2, 3]
[3, 2, 1, 1, 2, 3]
-
An operator able to check whether two values are equal is code as:
-
The second assignment:
vals = [0, 1, 2]
vals[0], vlas[2] = vals[2], vals[0]
- doesn’t change the list
- reverses the list
- shortens the list
- extends the list
-
What is the output of the following snippet?
t = [[3-i for i in range (3)] for j in range (3)]
s = 0
for i in range(3):
s += t[i][i]
print(s)
-
The value eventually assigned to x
is equal to :
x = 1
x = x == x
-
How many elements does the my_list
list contain?
my_list = [i for i in range(-1, 2)]