PCEP-30-02
Free trial
Verified
Question 1
Insert the correct snippet so that the program produces the expected output.
Expected output:
Code:
- A: b = 0 not in list
- B: b = list[0]
- C: b = 0 in list
- D: b = False
Question 2
What will be the output of the following code snippet?
- A: 3
- B: 2
- C: 4
- D: 1
Question 3
What is the output of the following snippet?
- A: two
- B: one
- C: (‘one’, ‘two’, ‘three’)
- D: three
Question 4
What is the expected output of the following code?
- A: [3, 1, 25, 5, 20, 5, 4]
- B: [1, 3, 4, 5, 20, 5, 25]
- C: [3, 5, 20, 5, 25, 1, 3]
- D: [1, 3, 3, 4, 5, 5, 20, 25]
- E: [3, 4, 5, 20, 5, 25, 1, 3]
Question 5
Which of the following sentences is true?
- A: str1 and str2 are different (but equal) strings.
- B: str1 and str2 are different names of the same strings.
- C: str1 is longer than str2
- D: str2 is longer than str1
Question 6
The fact that tuples belong to sequence types means:
- A: they can be modified using the del instruction
- B: they can be extended using the .append() method
- C: they are actually lists
- D: they can be indexed and sliced like lists
Question 7
What is the output of the following code?
- A: [1, 1, 1]
- B: [3, -1, 1]
- C: [3, 1, 1]
Question 8
What is the expected output of the following code?
- A: The code is erroneous.
- B: 6
- C: 5
- D: 4
Question 9
What is the expected output of the following code?
- A: ('Peter': 30, 'Paul': 31)
- B: ('Peter', 'Paul')
- C: ['Peter': 30, 'Paul': 31]
- D: ['Peter', 'Paul']
Question 10
What is the output of the following snippet?
- A: 2
- B: 4
- C: The snippet is erroneous (invalid syntax)
Question 11
What is the expected output of the following code?
- A: (4)
- B: 4
- C: (4,)
- D: 44
Question 12
Assuming that the tuple is a correctly created tuple, the fact that tuples are immutable means that the following instruction:
- A: is illegal
- B: may be illegal if the tuple contains strings
- C: can be executed if and only if the tuple contains at least two elements
- D: is fully correct
Question 13
What is the output of the following snippet?
- A: [1, 1, 2, 2]
- B: [1, 1, 1, 2]
- C: [1, 2, 1, 2]
- D: [1, 2, 2, 2]
Question 14
What is the expected output of the following code?
- A: 4
- B: 6
- C: 5
- D: 3
Question 15
A data structure described as LIFO is actually a:
- A: stack
- B: tree
- C: list
- D: heap
Question 16
How would you remove all the items from the d dictionary?
Expected output:
Code:
- A: d.del()
- B: d.remove()
- C: del d
- D: d.clear()
Question 17
What is the expected output of the following code?
- A: three
- B: ('one', 'two', 'three')
- C: two
- D: one
Question 18
What is the expected output of the following code?
- A: False
- B: 1
- C: 0
- D: True
Question 19
Which one of the lines should you put in the snippet below to match the expected output?
Expected output:
Code:
- A: reverse(list)
- B: list.reversed()
- C: list.reverse()
- D: reversed(list)
Question 20
What is the expected output of the following code?
- A: ['1', '2', '3', '4']
- B: (1, 2, 3, 4)
- C: ('1', '2', '3', '4')
- D: The code is erroneous.
Question 21
What is the expected output of the following code?
- A: (2)
- B: (2,)
- C: 2
- D: The code is erroneous.
Question 22
What is the output of the following snippet?
- A: -2
- B: 3
- C: -1
- D: 1
Question 23
What is the expected output of the following code?
- A: 2
- B: 4
- C: 5
- D: 3
Question 24
An alternative name for a data structure called a stack is:
- A: LIFO
- B: FIFO
- C: FOLO
Question 25
What is the expected output of the following code?
- A: [7, 3, 23, 42]
- B: [7, 20, 23, 42]
- C: [10, 20, 42]
- D: [10, 20, 23, 42]
Free preview mode
Enjoy the free questions and consider upgrading to gain full access!