Quiz
Python - Módulo 2
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (20)
1An operator able to check whether two values are equal is coded as:
- A=
- B===
- C==
- D!=
2The value eventually assigned to x is equal to:
x = 1
x = x == x- AFalse
- B1
- CTrue
- D0
3How many stars will the following snippet send to the console?
i = 0
while i <= 3 :
i += 2
print(“*”)- Atwo
- Bthree
- Cone
- Dzero
4How many stars will the following snippet send to the console?
i = 0
while i <= 5 :
i += 1
if i % 2 == 0:
break
print(“*”)- Azero
- Bone
- Ctwo
- Dthree
5How many hashes will the following snippet send to the console?
for i in range(1):
print(“#”)
else:
print(“#”)- Aone
- Btwo
- Czero
- Dthree
6How many hashes will the following snippet send to the console?
var = 0
while var < 6:
var += 1
if var % 2 == 0:
continue
print(“#”)- Atwo
- Bzero
- Cone
- Dthree
7How many hashes will the following snippet send to the console?
var = 1
while var < 10:
print(“#”)
var = var << 1- Aeight
- Bone
- Cfour
- Dtwo
8What value will be assigned to the x variable?
z = 10
y = 0
x = y < z and z > y or y > z and z < y- A0
- B1
- CTrue
- DFalse
9What is the output of the following snippet?
a = 1
b = 0
c = a & b
d = a | b
e = a ^ b
print(c + d + e)- A1
- B3
- C2
- D0
10What is the output of the following snippet?
lst = [3, 1, -2]
print(lst[lst[-1]])- A1
- B-2
- C3
- D-1
11What is the output of the following snippet?
lst = [1,2,3,4]
print(lst[-3:-2])- A[2,3]
- B[]
- C[2]
- D[2,3,4]
12The second assignment:
vals = [0, 1, 2]
vals[0], vals[2] = vals[2], vals[0]- Areverses the list
- Bshortens the list
- Cextends the list
- Ddoesn’t change the list
13After execution of the following snippet, the sum of all vals elements will be equal to:
vals = [0, 1, 2]
vals.insert(0,1)
del vals[1]- A2
- B5
- C3
- D4
14Take a look at the snippet, and choose the true statement:
nums = [1,2,3]
vals = nums
del vals[1:2]- Athe snippet will cause a runtime error
- Bnums and vals are of the same length
- Cvals is longer than nums
- Dnums is longer than vals
15Which of the following sentences is true?
nums = [1,2,3]
vals = nums[-1:-2]- Avals is longer than nums
- Bthe snippet will cause a runtime error
- Cnums and vals are of the same length
- Dnums is longer than vals
16What is the output of the following snippet?
l1 = [1,2,3]
l2 = []
for v in l1:
l2.insert(0,v)
print(l2)- A[3,2,1]
- B[1,2,3]
- C[3,3,3]
- D[1,1,1]
17What is the output of the following snippet?
l1 = [1,2,3]
for v in range(len(l1)):
l1.insert(1,l1[v])
print(l1)- A[1, 2, 3, 3, 2, 1]
- B[3, 2, 1, 1, 2, 3]
- C[1, 1, 1, 1, 2, 3]
- D[1, 2, 3, 1, 2, 3]
18How many elements does the L list contain?
L = [i for i in range(-1,2)]- Aone
- Bfour
- Cthree
- Dtwo
19What 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)- A4
- B2
- C7
- D6
20What is the output of the following snippet?
L = [[0, 1, 2, 3] for i in range(2)]
print(L[2][0])- A1
- B2
- C0
- Dthe snippet will cause a runtime error
Information
- Description
- Informática (Entornos de Desarrollo) Quiz on Python - Módulo 2, created by Cristina Sierra Segura on 24/04/2019.
- Author
- Cristina Sierra Segura
- Language
- Español
- Views
- 19
- Tags
- Rating
- No ratings yet Rate this quiz