PCEP-30-02Free trialFree trial

By python-institute
Aug, 2025

Verified

25Q per page

Question 1

Insert the correct snippet so that the program produces the expected output.
Expected output:

Image 1

Code:

Image 2
  • 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?

Image 1
  • A: 3
  • B: 2
  • C: 4
  • D: 1

Question 3

What is the output of the following snippet?

Image 1
  • A: two
  • B: one
  • C: (‘one’, ‘two’, ‘three’)
  • D: three

Question 4

What is the expected output of the following code?

Image 1
  • 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?

Image 1
  • 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?

Image 1
  • A: [1, 1, 1]
  • B: [3, -1, 1]
  • C: [3, 1, 1]

Question 8

What is the expected output of the following code?

Image 1
  • A: The code is erroneous.
  • B: 6
  • C: 5
  • D: 4

Question 9

What is the expected output of the following code?

Image 1
  • 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?

Image 1
  • A: 2
  • B: 4
  • C: The snippet is erroneous (invalid syntax)

Question 11

What is the expected output of the following code?

Image 1
  • 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:

Image 1
  • 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?

Image 1
  • 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?

Image 1
  • 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:

Image 1

Code:

Image 2
  • A: d.del()
  • B: d.remove()
  • C: del d
  • D: d.clear()

Question 17

What is the expected output of the following code?

Image 1
  • A: three
  • B: ('one', 'two', 'three')
  • C: two
  • D: one

Question 18

What is the expected output of the following code?

Image 1
  • 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:

Image 1

Code:

Image 2
  • A: reverse(list)
  • B: list.reversed()
  • C: list.reverse()
  • D: reversed(list)

Question 20

What is the expected output of the following code?

Image 1
  • 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?

Image 1
  • A: (2)
  • B: (2,)
  • C: 2
  • D: The code is erroneous.

Question 22

What is the output of the following snippet?

Image 1
  • A: -2
  • B: 3
  • C: -1
  • D: 1

Question 23

What is the expected output of the following code?

Image 1
  • 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?

Image 1
  • A: [7, 3, 23, 42]
  • B: [7, 20, 23, 42]
  • C: [10, 20, 42]
  • D: [10, 20, 23, 42]
Page 1 of 14 • Questions 1-25 of 331

Free preview mode

Enjoy the free questions and consider upgrading to gain full access!