python institute PCAP-31-03 Exam Questions

Questions for the PCAP-31-03 were updated on : Nov 21 ,2025

Page 1 out of 10. Viewing questions 1-15 out of 147

Question 1

What is the expected behavior of the following code?

  • A. it outputs -2
  • B. it outputs 2. 0
  • C. it outputs 0. 0
  • D. the code is erroneous and it will not execute
Answer:

A

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 2

Assuming that the code below has been placed inside a file named code.py and executed
successfully which of the following expressions evaluate to True? (Select two answers)

  • A. str (Object) = 'Object1
  • B. Class A.__module__ == ' main__'
  • C. len (ClassB.__bases__) == 2
  • D. __name__== '__main__'
Answer:

B, C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 3

What is the expected behavior of the following code?

  • A. It outputs 123
  • B. it raises an exception
  • C. it outputs 321
  • D. it outputs 6
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 4

Which of the following expressions evaluate to True? (Select two answers)

  • A. 11 == '011'
  • B. 3 * 'a' < 'a' * 2
  • C. 'abc' .upper () < 'abc'
  • D. '1' + '2' * 2 !=2 '12'
Answer:

C, D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 5

Which of the following invocations are valid? (Select two answers)

  • A. sorted ("python'')
  • B. "python" .sort ( )
  • C. sort" ("python")
  • D. "python' ,find (" ")
Answer:

A, D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 6

What is the expected output of the following code?

  • A. a
  • B. an exception is raised
  • C. b
  • D. c
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 7

What is the expected output of the following code?

  • A. 2
  • B. 3
  • C. 4
  • D. an exception is raised
Answer:

A

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 8

Assuming that the following piece of code has been executed successfully, which of the expressions
evaluate to True? (Select two answers)

  • A. is instance(obj_b,C)
  • B. C._C__VarA == 2
  • C. has atr (B, 'get')
  • D. obj_c.get() == 2
Answer:

C, D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 9

Which of the following expressions evaluate to True? (Select two answers)

  • A. 121 +1 == int ('1' + 2 * '2')
  • B. float ('3.14') == str('3.'+'14')
  • C. 'xyz'.lower() 'XY'
  • D. '8' + '8' !=2 * '8'
Answer:

A, C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 10

Which of the following statements are true? (Select two answers)

  • A. open () is a function which returns an int that represents a physical file handle
  • B. the second open () argument is optional
  • C. instd, outstd, errstd are the names of pre-opened streams
  • D. if invoking open () fails, the value None is returned
Answer:

A, B

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 11

Assuming that the following code has been executed successfully, select the expressions which
evaluate to True (Select two answers.)

  • A. a is not None
  • B. a ! =b
  • C. b () ==4
  • D. a () == 4
Answer:

B, D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 12

The__bases__property contains:

  • A. base class locations (addr)
  • B. base class objects (class)
  • C. base class names (str)
  • D. base class ids (int)
Answer:

C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 13

What is the expected behavior of the following code?

  • A. it outputs 2
  • B. it raises an exception
  • C. it outputs 3
  • D. it outputs 5
Answer:

D

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 14

Which of the following expressions evaluate to True? (Select two answers)

  • A. len ('' ' '') == 2
  • B. len ( ' ' ' 12 34 ' ' ') == 4
  • C. chr (ord('z') - 1 == 'Y'
  • D. ord (''0'') - ord (''9'') == 10
Answer:

A, C

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000

Question 15

What is the expected behavior of the following code?

  • A. it outputs False
  • B. it outputs True
  • C. it raises an exception
  • D. it outputs nothing
Answer:

A

User Votes:
A
50%
B
50%
C
50%
D
50%

Discussions
vote your answer:
A
B
C
D
0 / 1000
To page 2