PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 89


Which of the following expressions evaluate to True? (Choose two.)

Show Answer
Correct Answer: BD

The expression 'dcb' not in 'abcde'[::-1] evaluates to False because the reverse of 'abcde' is 'edcba', which contains 'dcb'. Therefore, 'dcb' not in 'edcba' is False. However, as the question is which evaluate to True, 'True' not in 'False' is correct because the substring 'True' does not exist within the string 'False', making this condition True. The expressions 'str(1-1) in '123456789'[:2]' evaluates to False since '0' is not in '12'. Similarly, 'phd' in 'aplpha' evaluates to False because there is no substring 'phd' in 'aplpha'. Therefore, the correct answers are B and D.

Discussion

12 comments
Sign in to comment
aferiverOptions: AD
Apr 13, 2023

Correct text is: A. str(1-1) in '0123456789' B. 'dcb' not in 'abcde'[::-1] C. 'phd' in 'alpha' D. 'True' not in 'False' A. str(1-1) in ‘0123456789’ evaluates to True because str(1-1) is ‘0’ which is in ‘0123456789’. B. ‘dcb’ not in ‘abcde’[::-1] evaluates to False because ‘dcb’ is in the reversed string ‘edcba’. C. ‘phd’ in ‘alpha’ evaluates to False because there is no substring ‘phd’ in the string ‘alpha’. D. ‘True’ not in ‘False’ evaluates to True because the string ‘True’ is not a substring of the string ‘False’.

swatiphadtare
May 6, 2023

@aferiver - did you give exam recently? how many new questions?

Jnanada
Aug 19, 2022

Only D is correct

mazimir
Oct 20, 2021

Exception True False True

techdawgs
Dec 5, 2021

It also comes down to what is supposed to be the correct text. I have come across this question elsewhere with the below answers which would mean A & D were correct. A. str(1-1) in '0123456789' B. 'dcb' not in 'abcde'[::-1] C. 'phd' in 'alpha' D. 'True' not in 'False'

stuartz
Jun 16, 2022

Did the options change from: A. str(1-1) in '123456789'[:2] '0' in '12' is False B. 'dcb' not in 'abcde'[::-1] 'dcv not in 'edcba' is False C. 'phd' in 'aplpha' definitely False D. 'True' not in 'False' Only D is True

stuartz
Jun 16, 2022

edit: 'dcb' not in 'edcba' is False

macxszOption: D
May 4, 2022

As it is, only True is: D. 'True' not in 'False'

carpmatiasOptions: BD
May 11, 2022

Definetely B and D: >>> 'dcb' not in 'abcde[1-::]' True >>> 'True' not in 'False' True

Damon54
Feb 7, 2024

There is something wrong with the choices print (str(1-1) in '123456789'[:2]) print ('dcb' not in 'abcde'[::-1]) print ('phd' in 'aplpha') print ('True' not in 'False') False False False True

Noarmy315
Dec 31, 2021

AD is correct

rocky48Options: BD
Mar 19, 2022

str(1-1) in [2:]"123456789" File "<stdin>", line 1 str(1-1) in [2:]"123456789" ^ SyntaxError: invalid syntax >>> 'dcb' not in 'abcde[1-::]' True >>> 'phd' in 'aplpha' False >>> 'True' not in 'False' True So its BD

zantrz
Feb 3, 2024

before providing any answer, please place the code into any IDE. In Pycharm: print("dcb" not in "abcde"[::-1]) returns False. To clarify, in the expression "dcb" not in "abcde"[::-1], the substring 'dcb' is indeed present in the reversed string 'edcba'. Therefore, the correct evaluation is False, not True.

zantrzOptions: AD
Feb 3, 2024

str(1-1) in '0123456789'

Damon54
Feb 7, 2024

print (str(1-1) in '123456789'[:2]) False

Dave304409Options: BD
Apr 15, 2025

is correct