Exam PCAP All QuestionsBrowse all questions from this exam
Question 89

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

    Correct Answer: B, D

    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
aferiverOptions: AD

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

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

Jnanada

Only D is correct

mazimir

Exception True False True

techdawgs

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'

stuartzOption: D

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

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

carpmatiasOptions: BD

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

macxszOption: D

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

Damon54Option: D

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

Damon54Options: BD

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

zantrzOptions: AD

str(1-1) in '0123456789'

rocky48Options: BD

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

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.

Noarmy315Options: AD

AD is correct