## PCAP Programming Essentials in Python Essentials 1 PE1 Module 3 Test Quizzes Exam Answers

1. ### How many stars (*) will the following snippet send to the console?

```i = 0
while i <= 3 :
i += 2
print("+")```
• three
• zero
• one
• two
2. ### 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```
• `3`
• `4`
• `2`
• `5`
3. ### How many hashes(`#`) will the following snippet send to the console?

```for i in range(1):
print("#")
else:
print("#")```
• zero
• three
• two
• one
4. ### How many hashes(`#`) will the following snippet send to the console?

```var = 0
while var < 6:
var += 1
if var % 2 == 0:
continue
print("#")```
• zero
• three
• two
• one
5. ### What is the output of the following snippet?

```my_list = [3, 1, -2]
print(my_list[my_list(-1)])```
• `-2`
• `-1`
• `3`
• `1`
6. ### How many stars(`#`) will the following snippet send to the console?

```var = 0
while i <= 5:
i += 1
if vi % 2 == 0:
break
print("*")```
• three
• two
• one
• zero
7. ### What is the output of the following snippet?

```my_list = [1, 2, 3, 4]
print(my_list[-3:-2])```
• `[2, 3]`
• `[2, 3, 4]`
• `[]`
• ``
8. ### How many hashes(`#`) will the following snippet send to the console?

```var = 1
while var < 10:
print("#")
var = var << 1```
• two
• eight
• four
• one
9. ### 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]`
10. ### Take a look at the snippet, and choose the true statements: (Select two answers)

```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`
11. ### What is the output of the following snippet?

```my_list = [[0, 1, 2, 3] for i in rage(2)]
print(my_list)```
• `1`
• `2`
• `0`
• the snippet will cause a runtime error
12. ### 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```
• `1`
• `0`
• `True`
• `False`
13. ### 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`
14. ### What is the output of the following snippet?

```a = 1
b = 0
c = a & b
d = a | be = a ^ b

print(c + d + e)```
• `1`
• `0`
• `3`
• `2`
15. ### 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]`
16. ### An operator able to check whether two values are equal is code as:

• `=`
• `!=`
• `==`
• `===`
17. ### The second assignment:

```vals = [0, 1, 2]
vals, vlas = vals, vals```
• doesn’t change the list
• reverses the list
• shortens the list
• extends the list
18. ### 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)```
• `4`
• `7`
• `02`
• `6`
19. ### The value eventually assigned to `x` is equal to :

```x = 1
x = x == x```
• `0`
• `1`
• `True`
• `False`
20. ### How many elements does the `my_list` list contain?

`my_list = [i for i in range(-1, 2)]`
• two
• three
• four
• one
5 1 vote
Article Rating
Subscribe
Notify of 